dthree / vorpal

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

Argument detected as option #304

Open chapterjason opened 6 years ago

chapterjason commented 6 years ago

I use Vorpal for a short time and recently found the following issue.

This is my code:

const vorpal = require('vorpal')();

vorpal.command('add [text...]', '...')
    .types({ string: ['text'] })
    .action(function(args, cb){
        console.log(args);
        cb();
    });

vorpal.execSync('add "-test"');

The output is the following:

  Invalid option: 't'. Showing Help:

  Usage: add [options] [text...]

  ...

  Options:

    --help  output usage information

After some debugging I found out that https://github.com/dthree/vorpal/blob/master/lib/util.js#L22 is removing the quotes.

zyuhel commented 6 years ago

Run into the same problem. That behaviour breaks usage of any strings started with -

Also minimist seems to be unsupported for years substack/minimist#115 Maybe it should be replaced with yargs-parser Minimist2 at the moment breaks more tests. yargs-parser has only one integration test failed. And it will be possibly easier to fix. Also yargs-parser is actively maintained

Moving to yargs-parser seem to fix this bug