Skip to content

Commit 648af6b

Browse files
committed
Fix required service attribute
1 parent 80c2cba commit 648af6b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cmd/main.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,17 @@ var service string
2929

3030
var rootCmd = &cobra.Command{
3131
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
32-
if cmd.Name() != "list" && service == "" {
32+
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 == "" {
3343
return fmt.Errorf("--service flag is required for this command")
3444
}
3545

0 commit comments

Comments
 (0)