dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.34k stars 375 forks source link

[Design] Are multiple option tokens supported for single value options (last one wins)? #2398

Open KathleenDollard opened 2 months ago

KalleOlaviNiemitalo commented 2 months ago

FWIW, if you call a function in Common Lisp and provide duplicate keyword arguments, then the first one wins. But I suppose this is for convenience with &REST and APPLY, which expands only the last argument as a list. In command-line scripting, PowerShell splatting and POSIX sh "$@" are similar features but they can be used at the start of the command line as well.

For command lines, I worry that allowing later options to override earlier ones by default may make it difficult for the application developer to convert the single-value option to a multiple-value option in a later version, without breaking compatibility. But I suppose such conversion is not common and, if the developer intends to do it later, they can make it a multiple-value option right at the start and validate that it has only one value. Although this would still allow completion to suggest additional values…? Oh right, ArgumentArity is better for this than a validator, as it can be recognized by the completion engine.