cobra icon indicating copy to clipboard operation
cobra copied to clipboard

Override help subcommand logic

Open firelizzard18 opened this issue 4 months ago • 2 comments

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.

firelizzard18 avatar Apr 24 '24 21:04 firelizzard18

#1559 does this for the completion command.

How would the help command be used in such a case though? The help command is usually used as program help subcommand

marckhouzam avatar Apr 24 '24 22:04 marckhouzam

I use program help all the time to print the usage message. Sure, I could use program --help, but it's muscle memory at this point.

firelizzard18 avatar Apr 24 '24 23:04 firelizzard18