-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
My urfave/cli version is
3.3.8
Checklist
- Are you running the latest v3 release? The list of releases is here.
- Did you check the manual for your release? The v3 manual is here
- Did you perform a search about this problem? Here's the GitHub guide about searching.
Dependency Management
- My project is using go modules.
- My project is automatically downloading the latest version.
Describe the bug
When using the DefaultComment
property on the root command, define a subcommand, and then run all that without specifying a command, it seems like the parser still tries to match the first argument to a subcommand. Within the subcommand's Action cli.Command.Args will simply not include the first argument.
To reproduce
I've collected some test cases here: https://github.com/zerok/issue-urfave-cli-v3-defaultcmd-args
Observed behavior
The first argument as seen from the subcommand's Action is not present when DefaultCommand
is used and the command doesn't match.
Expected behavior
This should IMO either lead to an error or the parser checking the list of defined subcommands and warn if none could be matched and so the default command is used.
Additional context
Add any other context about the problem here.
If the issue relates to a specific open source GitHub repo, please
link that repo here.
If you can reproduce this issue with a public CI system, please
link a failing build here.
Want to fix this yourself?
I'm not completely sure if this is even a bug or just undocumented behavior. But if time permits and this is confirmed to be a bug, I'd like to work on this.
Run go version
and paste its output here
go version go1.24.4 darwin/arm64