diff --git a/internal/registry/cobra.go b/internal/registry/cobra.go index 2c993ca..04b13f1 100644 --- a/internal/registry/cobra.go +++ b/internal/registry/cobra.go @@ -57,7 +57,11 @@ func newCobraRoot(root *command.Command) *cobra.Command { func ToCobra(cmd *command.Command, globalOptions command.Options, parent *cobra.Command) *cobra.Command { localName := cmd.Name() useSpec := []string{localName, "[options]"} - for _, arg := range cmd.Arguments { + for idx, arg := range cmd.Arguments { + if arg == nil { + useSpec = append(useSpec, fmt.Sprintf("could not parse spec for argument %d of command %s", idx, cmd.FullName())) + continue + } useSpec = append(useSpec, arg.ToDesc()) } @@ -93,6 +97,10 @@ func ToCobra(cmd *command.Command, globalOptions command.Options, parent *cobra. cc.Flags().AddFlagSet(cmd.FlagSet()) for name, opt := range cmd.Options { + if opt == nil { + useSpec = append(useSpec, fmt.Sprintf("could not parse spec for option %s of command %s", name, cmd.FullName())) + continue + } if err := cc.RegisterFlagCompletionFunc(name, opt.CompletionFunction); err != nil { log.Errorf("Failed setting up autocompletion for option <%s> of command <%s>", name, cmd.FullName()) } diff --git a/internal/registry/registry.go b/internal/registry/registry.go index fb2d0d4..0df5616 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -105,7 +105,7 @@ func Execute(version string) error { container := ccRoot for idx, cp := range cmd.Path { if idx == len(cmd.Path)-1 { - if cmd.Action != nil { + if cmd.Action != nil && cmd.Cobra == nil { // nil actions come when the current command consists only // of metadata for a "group parent" command // and we don't wanna cobraize it like a regular, actionable one