Currently developing a vorpal application and am trying to add variadic support to one of my commands. However adding the variadic syntax to an option of the command does not seem to work as expected.
Example:
command: language set-active -l en fr nl
output: TypeError: Object en has no method 'join'
var vorpal = require('vorpal')();
// ... removed many commands for brevity of this example
vorpal
.command('language set-active')
.description('activate languages')
.option('-l, --languages [languages...]', 'Enter a list of language keys to activate')
.action(function(args, callback) {
console.log(args.options.languages.join(', '));
callback();
});
vorpal
.delimiter(vorpal.chalk.bold.yellow('blimp-cli~$'))
.show();
however when I change the variadic params from options into command arguments works perfectly:
command: language set-active en fr nl
output: output: en, fr, nl
// ...
vorpal
.command('language set-active [languages...]')
.description('activate languages')
.action(function(args, callback) {
console.log(args.options.languages.join(', '));
callback();
});
// ...
The recieved TypeError: Object en has no method 'join'
seems to me that the options flag parses the arguments wrong?
Sorry for the delay.
In looking further into this, Vorpal doesn't yet support variadic arguments for options, only commands.
Vorpal bases is option parsing largely off of the minimist
module, and this does not support variadic args by default, and the option parsing is a bit trickier than command parsing due to additional details.
I'll take this into account for a future version!