Filed by Claude on behalf of @silverwind
Description
PR #2245 introduced a regression in v3.6.2 where flag pre-parsing is skipped for any command named "help". This breaks applications that use flags with help subcommands, as the flags are never parsed.
The problematic change in command_run.go:
- if cmd.isCompletionCommand {
+ if cmd.isCompletionCommand || cmd.Name == helpName {
tracef("special command detected, skipping pre-parse (cmd=%[1]q)", cmd.Name)
cmd.parsedArgs = args
return ctx, cmd.Action(ctx, cmd)
}
By matching on cmd.Name == helpName, this skips pre-parsing for ALL commands named "help", not just the internal completion command. This causes flags passed to help subcommands (e.g. myapp help -c mycmd) to be silently ignored.
Steps to reproduce
- Define a CLI app with a flag (e.g.
-c) on the help command
- Run
myapp help -c value
- The flag value is never parsed
Expected behavior
Flags should be parsed normally for help commands, as they were in v3.6.1.
Actual behavior
Flag pre-parsing is skipped entirely, flags are ignored.
Workaround
Pin urfave/cli/v3 to v3.6.1 or earlier via replace directive in go.mod.
Related