Skip to content

chore: remove urlfave/cli built-in -h flag that is causing confusing behavior#2294

Open
Stratus3D wants to merge 8 commits into
masterfrom
tb/remove-global-h-flag
Open

chore: remove urlfave/cli built-in -h flag that is causing confusing behavior#2294
Stratus3D wants to merge 8 commits into
masterfrom
tb/remove-global-h-flag

Conversation

@Stratus3D

@Stratus3D Stratus3D commented Jul 8, 2026

Copy link
Copy Markdown
Member
  • Disable urfave/cli help command and global help flag
  • Print asdf help when no subcommand is specified
  • Print asdf help with error message when unknown subcommand is specified

This fixes what was reported in #2228

Comment thread internal/cli/cli.go
log.SetFlags(0)

app := &cli.Command{
HideHelp: true,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't generate the global --help/-h flag or the urlfave/cli generated help command. Our own help subcommand is better. The -h help flag behavior was also confusing in contexts where the user did not intend to request the help output.

Comment thread internal/cli/cli.go
Action: func(_ context.Context, cmd *cli.Command) error {
// If no args, show help
if cmd.Args().Len() == 0 {
return helpCommand(logger, version, "", "")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show asdf's custom help output if no subcommand is specified.

Comment thread test/set_command.bats
[[ "$output" == *"No .tool-versions version file found in parent directory"* ]]
}

@test "set with -h flag should show error for undefined flag" {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the above changes this test would fail.

Comment thread internal/cli/cli.go
Version: version,
Copyright: "(c) 2024 Trevor Brown",
Authors: []any{
mail.Address{Name: "Trevor Brown", Address: "someguy@example.com"},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my email address.

@Stratus3D Stratus3D marked this pull request as ready for review July 9, 2026 01:13
@Stratus3D Stratus3D requested a review from a team as a code owner July 9, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant