prompt
Advanced tools
Comparing version 0.2.11 to 0.2.12
@@ -147,3 +147,3 @@ /* | ||
if (~names.indexOf(search)) { | ||
if (!~names.indexOf(search)) { | ||
return null; | ||
@@ -150,0 +150,0 @@ } |
{ | ||
"name": "prompt", | ||
"description": "A beautiful command-line prompt for node.js", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"author": "Nodejitsu Inc. <info@nodejitsu.com>", | ||
@@ -6,0 +6,0 @@ "maintainers": [ |
@@ -41,3 +41,3 @@ # prompt [![Build Status](https://secure.travis-ci.org/flatiron/prompt.png)](http://travis-ci.org/flatiron/prompt) | ||
``` | ||
$ node examples/simple-prompt.js | ||
$ node examples/simple-prompt.js | ||
prompt: username: some-user | ||
@@ -85,3 +85,3 @@ prompt: email: some-user@some-place.org | ||
Pretty easy right? The output from the above script is: | ||
Pretty easy right? The output from the above script is: | ||
@@ -94,6 +94,6 @@ ``` | ||
prompt: name: Nodejitsu Inc | ||
prompt: password: | ||
prompt: password: | ||
Command-line input received: | ||
name: Nodejitsu Inc | ||
password: some-password | ||
password: some-password | ||
``` | ||
@@ -170,4 +170,4 @@ | ||
Sometimes power users may wish to skip promts and specify all data as command line options. | ||
if a value is set as a property of `prompt.override` prompt will use that instead of | ||
Sometimes power users may wish to skip promts and specify all data as command line options. | ||
if a value is set as a property of `prompt.override` prompt will use that instead of | ||
prompting the user. | ||
@@ -207,4 +207,4 @@ | ||
### Adding Properties to an Object | ||
A common use-case for prompting users for data from the command-line is to extend or create a configuration object that is passed onto the entry-point method for your CLI tool. `prompt` exposes a convenience method for doing just this: | ||
### Adding Properties to an Object | ||
A common use-case for prompting users for data from the command-line is to extend or create a configuration object that is passed onto the entry-point method for your CLI tool. `prompt` exposes a convenience method for doing just this: | ||
@@ -235,2 +235,26 @@ ``` js | ||
### Prompt history | ||
You can use the `prompt.history()` method to get access to previous prompt input. | ||
``` js | ||
prompt.get([{ | ||
name: 'name', | ||
description: 'Your name', | ||
type: 'string', | ||
require: true | ||
}, { | ||
name: 'surname', | ||
description: 'Your surname', | ||
type: 'string', | ||
require: true, | ||
message: 'Please dont use the demo credentials', | ||
conform: function(surname) { | ||
var name = prompt.history('name').value; | ||
return (name !== 'John' || surname !== 'Smith'); | ||
} | ||
}], function(err, results) { | ||
console.log(results); | ||
}); | ||
``` | ||
## Customizing your prompt | ||
@@ -291,3 +315,3 @@ Aside from changing `property.message`, you can also change `prompt.message` | ||
``` bash | ||
``` bash | ||
$ npm test | ||
@@ -294,0 +318,0 @@ ``` |
@@ -394,3 +394,3 @@ /* | ||
} | ||
} | ||
} | ||
}, this.callback); | ||
@@ -474,2 +474,4 @@ helpers.stdin.writeNextTick('fn456\n'); | ||
assert.equal(result.sound, 'woof'); | ||
assert.equal(prompt.history('nothing'), null); | ||
assert.deepEqual(prompt.history('animal'), { property: 'animal', value: 'dog' }); | ||
} | ||
@@ -549,3 +551,3 @@ }, | ||
}, { | ||
default: 'yes' | ||
default: 'yes' | ||
}) | ||
@@ -625,3 +627,3 @@ ).addBatch( | ||
response: 'jitsu' | ||
}) | ||
}) | ||
).addBatch( | ||
@@ -631,3 +633,3 @@ macros.shouldConfirm({ | ||
prop: ["test", "test2", "test3"], | ||
response: ['Y\n', 'y\n', 'YES\n'] | ||
response: ['Y\n', 'y\n', 'YES\n'] | ||
}) | ||
@@ -638,3 +640,3 @@ ).addBatch( | ||
prop: ["test", "test2", "test3"], | ||
response: ['Y\n', 'N\n', 'YES\n'] | ||
response: ['Y\n', 'N\n', 'YES\n'] | ||
}) | ||
@@ -645,3 +647,3 @@ ).addBatch( | ||
prop: ["test", "test2", "test3"], | ||
response: ['n\n', 'NO\n', 'N\n'] | ||
response: ['n\n', 'NO\n', 'N\n'] | ||
}) | ||
@@ -655,4 +657,4 @@ ).addBatch( | ||
], | ||
response: ['y\n', 'y\n'] | ||
}) | ||
response: ['y\n', 'y\n'] | ||
}) | ||
).addBatch( | ||
@@ -665,3 +667,3 @@ macros.shouldNotConfirm({ | ||
], | ||
response: ['n\n', 'n\n'] | ||
response: ['n\n', 'n\n'] | ||
}) | ||
@@ -675,4 +677,4 @@ ).addBatch( | ||
], | ||
response: ['n\n', 'y\n'] | ||
}) | ||
response: ['n\n', 'y\n'] | ||
}) | ||
).export(module); |
117941
2104
318