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
swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: x86_64-apple-macosx12.0
There seems to be some inconsistencies for how default subcommands behave.
I think they probably stem from applying arguments that could work on the command to the default subcommand instead of to the command.
I would think that all arguments that can apply to the command should be applied to the command until the first argument that cannot be applied to the command. If that argument matches a subcommand name, obviously use the matching subcommand. If it doesn't match a subcommand name, then try to apply that & all subsequent arguments to the default subcommand.
Whatever behavior is chosen will affect how generated shell completion scripts should behave.
Checklist
If possible, I've reproduced the issue using the main branch of this package
$ ./.build/debug/math --version 1.0.0## the following seems to be trying to use `add` as an argument to the default subcommand `add`,## but it only accepts integers positionals
$ ./.build/debug/math --version addError: The value 'add' is invalid for '<values>'Help: <values> A group of integers to operate on.Usage: math add [--hex-output] [<values> ...] See 'math add --help' for more information.## the following seems to be trying to use `add` as an argument to the default subcommand `add`,## but it only accepts integers positionals
$ ./.build/debug/math --version add 1 2Error: The value 'add' is invalid for '<values>'Help: <values> A group of integers to operate on.Usage: math add [--hex-output] [<values> ...] See 'math add --help' for more information.
$ ./.build/debug/math add --version1.0.0
$ ./.build/debug/math add0
$ ./.build/debug/math add 1 23
If the default subcommand is removed from the math testing command:
ArgumentParser version:
main
Swift version:
There seems to be some inconsistencies for how default subcommands behave.
I think they probably stem from applying arguments that could work on the command to the default subcommand instead of to the command.
I would think that all arguments that can apply to the command should be applied to the command until the first argument that cannot be applied to the command. If that argument matches a subcommand name, obviously use the matching subcommand. If it doesn't match a subcommand name, then try to apply that & all subsequent arguments to the default subcommand.
Whatever behavior is chosen will affect how generated shell completion scripts should behave.
Checklist
main
branch of this packageSteps to Reproduce
Using the
math
testing command:If the default subcommand is removed from the
math
testing command:Expected behavior
The same output as the examples for
math
without the default command.Actual behavior
The output of the examples for
math
as it is in the codebase, i.e. withadd
as its default command. Specifically, the 2 errors indicate the issue.The text was updated successfully, but these errors were encountered: