diff options
author | Minteck <contact@minteck.org> | 2021-12-21 16:50:49 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2021-12-21 16:50:49 +0100 |
commit | 20204baf1807825af4798ad03bfb329e4da05bc5 (patch) | |
tree | 1568515fa1e4592206ed5d2327b39e6b443cbd03 /node_modules/prompt/examples/property-prompt.js | |
download | bingoloto-remote-20204baf1807825af4798ad03bfb329e4da05bc5.tar.gz bingoloto-remote-20204baf1807825af4798ad03bfb329e4da05bc5.tar.bz2 bingoloto-remote-20204baf1807825af4798ad03bfb329e4da05bc5.zip |
Commit
Diffstat (limited to 'node_modules/prompt/examples/property-prompt.js')
-rw-r--r-- | node_modules/prompt/examples/property-prompt.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/node_modules/prompt/examples/property-prompt.js b/node_modules/prompt/examples/property-prompt.js new file mode 100644 index 0000000..c8b343b --- /dev/null +++ b/node_modules/prompt/examples/property-prompt.js @@ -0,0 +1,45 @@ +/* + * property-prompt.js: Example of using prompt with complex properties. + * + * (C) 2010, Nodejitsu Inc. + * + */ + +var prompt = require('../lib/prompt'); + +var schema = { + properties: { + name: { + pattern: /^[a-zA-Z\s-]+$/, + message: 'Name must be only letters, spaces, or dashes', + required: true + }, + email: { + name: 'email', + format: 'email', + message: 'Must be a valid email address' + }, + password: { + required: true, + hidden: true + } + } +}; + +// +// Start the prompt +// +prompt.start(); + +// +// Get two properties from the user: email, password +// +prompt.get(schema, function (err, result) { + // + // Log the results. + // + console.log('Command-line input received:'); + console.log(' name: ' + result.name); + console.log(' email: ' + result.email); + console.log(' password: ' + result.password); +}); |