You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cli.command("echo [arg]","echo the input back",{variadic: true}).action((arg: string[])=>{console.log(arg);console.log(arg.join(" "));});
$ cli this is a message
[ "this", "is", "a", "message" ]
this is a message
$ cli "this is a message"
[ "this is a message" ]
this is a message
In other words, allow the final argument of a command to be marked as variadic without the spread operator. This would make things a little more ergonomic when working with commands where you're input sentences/longer strings - you could do either.
Actual
Currently, the behavior is of course available, but we need to use the spread operator convention.
cli.command("echo [...arg]","echo the input back").action((arg: string[])=>{console.log(arg);console.log(arg.join(" "));});
The issue with this convention is that [...arg] seems to be imply that the arguments are separate conceptual units.
cli
Usage:
$ cli <command> [options]
Commands:
echo [...arg] echo the input back
For more info, run any command with the `--help` flag:
$ sample-cli echo --help
This is not the case when we're entering single sentences, where a set of strings is separated by spaces. It's nice to just be able to do $ cli echo this is a sentence that I want to type unquoted.
The text was updated successfully, but these errors were encountered:
Issue Type
Expected
I'd like to be able to do the following:
In other words, allow the final argument of a command to be marked as variadic without the spread operator. This would make things a little more ergonomic when working with commands where you're input sentences/longer strings - you could do either.
Actual
Currently, the behavior is of course available, but we need to use the spread operator convention.
The issue with this convention is that
[...arg]
seems to be imply that the arguments are separate conceptual units.This is not the case when we're entering single sentences, where a set of strings is separated by spaces. It's nice to just be able to do
$ cli echo this is a sentence that I want to type unquoted
.The text was updated successfully, but these errors were encountered: