I am trying to use yargs for a command line application and I have run into a problem with my positional arguments.
I have:
require('yargs')
.command(
'my-command <value>',
'This command does someting'
(y) => {
return y
.option('my-option', {
describe: "Some option",
demandOption: true
})
}
(args) => {
//execute my command here
}
)
.help()
.completion()
.argv
This allows me to call:
my-program my-command my-value --my-option=hello!
And the args.value now contains "my-value".
So far so good. The problem however is that the 'value' argument does not show up in the help text. I would also like to restrict the value argument further, basically add a choices array to it. But I can only find how to do this using the .option() function which produces a -- flag. Such as for --my-option.
Is it possible to customize a positional argument in the same way as customizing a -- option?
It seems this is not supported. https://github.com/yargs/yargs/issues/541
And the issue is closed so likely will not be implemented any time soon.