We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 80c2cba commit 648af6bCopy full SHA for 648af6b
cmd/main.go
@@ -29,7 +29,17 @@ var service string
29
30
var rootCmd = &cobra.Command{
31
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
32
- if cmd.Name() != "list" && service == "" {
+ commandsWithoutService := []string{"completion", "help", "list", "version"}
33
+
34
+ serviceRequired := true
35
+ for _, c := range commandsWithoutService {
36
+ if cmd.Name() == c {
37
+ serviceRequired = false
38
+ break
39
+ }
40
41
42
+ if serviceRequired && service == "" {
43
return fmt.Errorf("--service flag is required for this command")
44
}
45
0 commit comments