diff --git a/cmd/main.go b/cmd/main.go index 5e03806..888ab96 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -29,7 +29,17 @@ var service string var rootCmd = &cobra.Command{ PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - if cmd.Name() != "list" && service == "" { + commandsWithoutService := []string{"completion", "help", "list", "version"} + + serviceRequired := true + for _, c := range commandsWithoutService { + if cmd.Name() == c { + serviceRequired = false + break + } + } + + if serviceRequired && service == "" { return fmt.Errorf("--service flag is required for this command") }