vorpal icon indicating copy to clipboard operation
vorpal copied to clipboard

Allow positional arguments to be treated as strings

Open jstoiko opened this issue 8 years ago • 1 comments

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

jstoiko avatar Feb 22 '17 20:02 jstoiko

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.

dthree avatar Apr 09 '17 16:04 dthree