coffee-toaster
Version:
Minimalist manager and build system for CoffeeScript, an alternative for AMD's or CJS's OOP patterns, but with similar results. Made for those who dare to use class definitions in CoffeeScript while being able to easily inherit from external files. Powered with imports directives that use wildcards facilities, exposed scopes and excluded files filter options. The system can even use folders-as-namespaces to help you avoid naming collisions in architecture.
20 lines (15 loc) • 439 B
text/coffeescript
class Question
ask:(question, format, fn)->
stdin = process.stdin
stdout = process.stdout
stdout.write "#{question} "
stdin.once( 'data', (data)=>
data = data.toString().trim()
if format.test data
fn data.trim()
else
msg = "#{'Invalid entry, it should match:'.red}"
rule = "#{format.toString().cyan}"
stdout.write "\t#{msg} #{rule}\n"
@ask question, format, fn
).resume()