deno-cliffy
deno-cliffy copied to clipboard
Args returns `any[][]`
With the following code
const { args } = await new Command()
.name("redirector")
.version("0.1.0")
.description("Create your own redirector service 🚀")
.arguments("<...urls>")
.parse(Deno.args);
console.log(args)
And executing it like this
deno run src/cli/redirector.ts build jeje
I got
[ [ "build", "jeje" ] ]
Why is the reason for this? Is not a big problem but is this the intended behavior?
What I would spect is
[ "build", "jeje" ]
Looks like this is intended: https://cliffy.io/[email protected]/command/commands#variadic-arguments
arguments
can include explicit positional arguments, with a variadic option at the end. The resulting args
array will have exactly one value for each item in the list – the variadic argument is expressed as a nested array.
For example, consider this command:
const { args } = await new Command()
.arguments("<arg1> <arg2> <...extras>")
.parse(Deno.args);
console.log(args)
When you run:
deno run rhyme.ts one two buckle my shoe
it outputs:
[ "one", "two", [ "buckle", "my", "shoe" ] ]
And the type of args
is actually [string, string, string[]]
