Closed cyc1e closed 1 year ago
Hi,
After reading the doc of commander I see that the module is missing a way to parse arguments.
However, the last argument of a command can be variadic, and only the last argument. To make an argument variadic you append ... to the argument name. A variadic argument is passed to the action handler as an array.
For example:
NOTE: Arguments do not support custom parsers, so you will receive strings even if you pass numbers. You could parse the receive array
myHandler(numbersAsString: string[]) {
const numbers = numbersAsString.map(n => parseFloat(n))
// ...
}
But I would like you to know that using options is more versatile than arguments https://github.com/Pop-Code/nestjs-console/wiki/Command-handler-signature#command-options
Hope this will help.
I close the issue, fell free to reopen it if you need.
Hi, first of all thanks for the great library. I can't find how can I pass the argument as an array of strings or numbers?