Last active
June 26, 2017 18:13
-
-
Save gretro/b67aa364967c3fa2c82279b7e4236c2e to your computer and use it in GitHub Desktop.
Vorpal REPL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vorpal = require('vorpal'); | |
const cli = vorpal(); | |
cli | |
.command('newprovider <handle> <name>', 'Creates a new provider, eg. `newprovider new "New provider"`') | |
.action(function(args, cb) { | |
const { handle, name } = args; | |
console.log(`Creating provider with handle ${handle} and name ${name}`); | |
this.prompt([ | |
{ | |
type: 'input', | |
name: 'url', | |
message: 'Enter a local path or a url of the provider logo ' | |
} | |
]).then(result => { | |
console.log(`URL: ${result.url}`); | |
cb(); | |
}); | |
}); | |
cli.show(); | |
cli.exec('newprovider fuzz "Fuzz Provider"', () => { | |
// Callback gets called AFTER the prompt has resolved. | |
console.log('Callback'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "vorpal", | |
"version": "1.0.0", | |
"description": "Spike for Vorpal exec with prompts", | |
"main": "index.js", | |
"scripts": { | |
"start": "node index.js --debug", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"vorpal": "^1.9.7" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment