diff options
Diffstat (limited to 'node_modules/prompt/examples/existing-properties.js')
-rw-r--r-- | node_modules/prompt/examples/existing-properties.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/node_modules/prompt/examples/existing-properties.js b/node_modules/prompt/examples/existing-properties.js new file mode 100644 index 0000000..d87503b --- /dev/null +++ b/node_modules/prompt/examples/existing-properties.js @@ -0,0 +1,35 @@ +/* + * existing-properties.js: Example of using prompt with predefined properties. + * + * (C) 2010, Nodejitsu Inc. + * + */ + +var prompt = require('../lib/prompt'); + +prompt.properties = { + email: { + format: 'email', + message: 'Must be a valid email address' + }, + password: { + hidden: true + } +}; + +// +// Start the prompt +// +prompt.start(); + +// +// Get two properties from the user: email, password +// +prompt.get(['email', 'password'], function (err, result) { + // + // Log the results. + // + console.log('Command-line input received:'); + console.log(' email: ' + result.email); + console.log(' password: ' + result.password); +}); |