Created
May 12, 2011 11:04
-
-
Save twilson63/968325 to your computer and use it in GitHub Desktop.
Ask Method for your Cakefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ask = (question, format, callback) -> | |
stdin = process.stdin | |
stdout = process.stdout | |
stdin.resume() | |
stdout.write "#{question}:" | |
stdin.once 'data', (data) -> | |
data = data.toString().trim() | |
if format.test(data) | |
callback data | |
else | |
stdout.write "It should match: #{format}\n" | |
ask(question, format, callback) |
Slick. Exactly what I needed. I really like the format feature.
(found via Forrst, btw)
You can also install via npm
npm install ask -g
then use in your cake files
{ ask } = require('ask')
Check out https://github.com/twilson63/ask
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
If you have coffeescript installed and you would like to create a simple command line interface to capture user input.
You can simply add this method to your cakefile, and then call it in your task. Ex: