vorpal
vorpal copied to clipboard
Allow positional arguments to be treated as strings
This PR allows specifying positional arguments names in .command.types(object). This is what the example from the wiki would look like once this is merged:
vorpal
.command('stringify <phone>')
.option('-a, --amount <amt>', 'A number to stringify.')
.types({
string: ['a', 'amount', 'phone']
})
.action(function (args, cb) {
this.log(args.options);
cb();
});
app~$ stringify 4238892 -a 7
{amount: '7', phone: '4238892'}
# Fields "amount" and "phone" would have otherwise been integers
This works with both optional, required and variadic arguments.
NOTE: this PR required https://github.com/substack/minimist/pull/113 to be merged first
LGTM, however doesn't look like that minimist PR went through, and I don't like the idea of pointing to a git repo from the dependencies.