Open
Description
Is your feature request related to a problem? Please describe.
I'd like the ability to define variadic arguments.
Describe the solution you'd like
static args = {
value: Args.string({
multiple: true,
})
}
console.log(this.args.value[0], this.args.value[1])
Describe alternatives you've considered
I've set "strict = false" and pulled the args from "const {argv} = await this.parse(..)" as it's called out in the docs: https://oclif.io/docs/args/. This means to use variadic arguments you lose the syntactic sugar (and documentation) of the args definition. You also lose validation (e.g. number / string / etc).
In other words, I want variadic arguments with strict parsing.
Additional context
Previous issues:
- Variadic arguments in oclif oclif#160. This was closed with a recommendation to disable strict parsing. This means you lose the validation.
- "multiple" flag for args oclif#293. This was closed with a link to a pull request in the oclif/parser repository. feat: allow multiple for arg parser#63. That repository has been archived.
Other tools:
- Commander supports variadic arguments: https://github.com/tj/commander.js?tab=readme-ov-file#variadic-option
- Clipanion (what Yarn Modern uses) supports variadic arguments via transparent proxying:
Option.Proxy
-- I've had to hack something like this together in oclif to support unknown flags so they can be forwarded without disabling strict parsing of known flags though that's a separate issue. - In Python, the stdlib for argument parsing supports variadic args via nargs: https://docs.python.org/3/library/argparse.html