Permalink
Browse files

OCD

  • Loading branch information...
1 parent 5b656f1 commit 2a2d59b3e641f8bb5a559912e5bea1f328c1bf80 @tj committed May 24, 2011
Showing with 8 additions and 6 deletions.
  1. +8 −6 bin/ngen
View
@@ -90,19 +90,17 @@ Template.prototype.init = function(dest){
var desc
, key = keys.shift();
- function yield(value) {
+ function done(value) {
self.values[key] = String(value).trim();
next();
}
if (key) {
desc = vars[key];
- // If `desc` is a function executing it so that it can read a value.
- if (typeof desc === "function") {
- desc(self.values, yield);
- // Otherwise falling back to CLI.
+ if ('function' == typeof desc) {
+ desc(self.values, done);
} else {
- ask(desc, yield);
+ ask(desc, done);
}
} else {
process.stdin.destroy();
@@ -197,6 +195,10 @@ function requireArgument(flag) {
}
}
+/**
+ * Ask for user input.
+ */
+
function ask(desc, callback) {
process.stdout.write(' \033[90m' + desc + '\033[0m');
process.stdin.setEncoding('utf8');

0 comments on commit 2a2d59b

Please sign in to comment.