-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose rawParse to use minimist/commander #5
Comments
You mean in addition to |
That's the idea, you'd map to minimist by default, with an optional second argument that'd run commander.js parse -- which would use your vorpal command list to return an object. Both are meant to be maps over to minimist/commander just in case it's needed. Related to using this: on vorpal.parse -- how do I detect whether or not a command was found? Is there a default callback, like parse(argv, notFoundFn)? |
It is meant to do exactly what you app does if you run it first. So it would technically display the help command. Check out the vorpal
.catch('[commands...]')
.option('-d, --detail', 'View detailed markdown on item.')
.option('-i, --install', 'View installation instructions.')
.autocompletion(function (text, iteration, cb) {
const self = this;
const index = parent.clerk.indexer.index();
let result = util.autocomplete(text, iteration, index, function (word, options) {
const res = self.match(word, options);
return res;
});
if (_.isArray(result)) {
result.sort();
}
cb(undefined, result);
})
.action(function (args, cb) {
const self = this;
args = args || {};
args.options = args.options || {};
// Handle humans.
if (String(args.commands[0]).toLowerCase() === 'wat') {
args.commands.shift();
}
// ...
cb();
});
Catch basically is called if you don't match on any other command, so it overrides help as the default function if no command is met. By adding in a |
On the parse, I think im gonna do this: var args = vorpal.parse(process.argv, { use: 'minimist' });
var args = vorpal.parse(process.argv, { use: 'commander' });
|
I like it. |
:) Does the catch thing make sense? |
Yes, it makes sense, does just what I want. |
Perfect. |
@Downchuck Added this. Coming out in a release today. |
…d-stupidity fix(package): Fixed repository.url to point at mulesoft fork
Vorpal could expose rawParse(process.argv, { command: true|false}) to run a string through minimist or commander. This may be a special case.
I have an existing app, it's just using minimist for cli arguments in the usual form (app.js --arg items), and I'm working on the interactive CLI via vorpal. Trying to reduce redundancy when I can.
I am still working out how best to switch between command line (single commands) and interactive command line. But that's a different issue.
The text was updated successfully, but these errors were encountered: