dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Allow positional arguments to be treated as strings #213

Closed jstoiko closed 11 months ago

jstoiko commented 7 years ago

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

dthree commented 7 years ago

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.