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

Subcommand Group panic: Group id 'Group1' is not defined for subcommand 'app1 sub1' #1830

Closed
KINGSABRI opened this issue Oct 16, 2022 · 1 comment

Comments

@KINGSABRI
Copy link

Hi everyone
I'm trying to implement to

  • root.go
func init() {
	cobra.EnableCaseInsensitive = true
	cobra.EnableCommandSorting = false

	rootCmd.CompletionOptions.DisableDefaultCmd = true 
	rootCmd.Flags().SortFlags = false
	rootCmd.PersistentFlags().SortFlags = false

	rootCmd.AddGroup(&cobra.Group{ID: "Group1", Title: "Group1 Subcommands:"})
}
  • sub1.go
var sub1Cmd = &cobra.Command{
	Use:     "sub1",
	GroupID: "Group1",
	Aliases: []string{"1"},
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Hiii")
	},
}

func init() {
	rootCmd.AddCommand(sub1Cmd)
	sub1Cmd.Flags().SortFlags = false
	sub1Cmd.Flags().StringP("ipaddress", "i", "0.0.0.0", "IP address to listen to")
}
@marckhouzam
Copy link
Collaborator

Duplicate of #1831

@marckhouzam marckhouzam marked this as a duplicate of #1831 Oct 17, 2022
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

No branches or pull requests

2 participants