spf13 / spf13/cobra

Override help subcommand logic

Open
#2,136 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
44.6k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

I am using cobra. I don't need subcommands. I do want the default help and completion subcommands to be generated. There should be an option for "generate default subcommands even if no other subcommands are defined".

func (c *Command) InitDefaultHelpCmd() {
	if !c.HasSubCommands() {
		return
	}
	// ...
}

There should be some option that disables the subcommand check.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Command.InitDefaultHelpCmd and the surrounding default-subcommand initialization, especially the HasSubCommands check. Trace how help and completion are generated, then determine the option's expected behavior when no user subcommands exist; done means both default subcommands can be generated in that case without changing normal behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.