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/dynamic-ask-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/dynamic-ask-prompt.js')
-rw-r--r-- | node_modules/prompt/examples/dynamic-ask-prompt.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/node_modules/prompt/examples/dynamic-ask-prompt.js b/node_modules/prompt/examples/dynamic-ask-prompt.js new file mode 100644 index 0000000..194e1ef --- /dev/null +++ b/node_modules/prompt/examples/dynamic-ask-prompt.js @@ -0,0 +1,38 @@ +/* + * dynamic-ask-prompt.js: Dynamically decide whether to display prompt. + */ + +var prompt = require('../lib/prompt'); + +var schema = { + properties: { + proxy: { + description: 'Proxy url' + }, + proxyCredentials: { + description: 'Proxy credentials', + ask: function() { + // only ask for proxy credentials if a proxy was set + return prompt.history('proxy').value > 0; + } + } + } +}; + +// +// Start the prompt +// +prompt.start(); + +// +// Get one or two properties from the user, depending on +// what the user answered for proxy +// +prompt.get(schema, function (err, result) { + // + // Log the results. + // + console.log('Command-line input received:'); + console.log(' proxy: ' + result.proxy); + console.log(' credentials: ' + result.proxyCredentials); +}); |