Wrong help output when a Command has "HideHelpCommand=true" but no defined subcommands
Opened this issue · 0 comments
fsufitch commented
My urfave/cli version is
v2.27.1
Checklist
- Are you running the latest v2 release? The list of releases is here.
- Did you check the manual for your release? The v2 manual is here
- Did you perform a search about this problem? Here's the GitHub guide about searching.
Dependency Management
- My project is automatically downloading the latest version.
Describe the bug
When HideHelpCommand
is set to true
on a command with no subcommands, the help text output by [...] mycmd --help
imples there are subcommands, when in fact there are none. By comparison, the text output by [...] help mycmd
is correct, though!
To reproduce
package main
import (
"fmt"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{Commands: []*cli.Command{{
Name: "foo",
HideHelpCommand: true, // <--- problem is here
}}}
app.Run([]string{"CMD", "help", "foo"})
fmt.Print("\n\n========================================\n\n")
app.Run([]string{"CMD", "foo", "--help"})
}
Observed behavior
The former execution presents the usage:
play foo [command options] [arguments...]
While the latter presents the (incorrect) usage:
play foo command [command options]
Expected behavior
The two outputs should match. The help calls are equivalent, and the latter output is misleading.
Additional context
Playground of the broken code: https://go.dev/play/p/kCuTCXk3Uxg
Run go version
and paste its output here
N/A (Go 1.22 in the Go Playground)
Run go env
and paste its output here
N/A (Go 1.22 in the Go Playground)