Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong help output when a Command has "HideHelpCommand=true" but no defined subcommands #1879

Open
3 tasks done
fsufitch opened this issue Mar 28, 2024 · 1 comment
Open
3 tasks done
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug

Comments

@fsufitch
Copy link

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)

@fsufitch fsufitch added area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug status/triage maintainers still need to look into this labels Mar 28, 2024
@meatballhat meatballhat removed the status/triage maintainers still need to look into this label Oct 13, 2024
@meatballhat
Copy link
Member

Belated thank you for the report @fsufitch 🙇🏼

meatballhat added a commit that referenced this issue Oct 14, 2024
to remove (confusing) difference between templates.

Closes #1879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v2 relates to / is being considered for v2 kind/bug describes or fixes a bug
Projects
None yet
Development

No branches or pull requests

2 participants