Skip to content

Instantly share code, notes, and snippets.

@gretro
Last active June 26, 2017 18:13
Show Gist options
  • Save gretro/b67aa364967c3fa2c82279b7e4236c2e to your computer and use it in GitHub Desktop.
Save gretro/b67aa364967c3fa2c82279b7e4236c2e to your computer and use it in GitHub Desktop.
Vorpal REPL
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');
});
{
"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