File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import (
2828
2929 "github.com/araddon/dateparse"
3030 "github.com/olekukonko/tablewriter"
31+ "github.com/spf13/cobra"
3132 gitlab "github.com/xanzy/go-gitlab"
3233
3334 "github.com/ghodss/yaml"
@@ -55,6 +56,16 @@ func newSetAtLeastOneFlagError(flags ...string) error {
5556 setAtLeastOneFlagError , strings .Join (flags , ", " ))
5657}
5758
59+ func validateFlagCombination (cmd * cobra.Command , mainFlag string , flags ... string ) error {
60+ for _ , fName := range flags {
61+ if cmd .Flag (fName ).Changed && ! cmd .Flag (mainFlag ).Changed {
62+ return fmt .Errorf ("'--%s' flag can only be used with '--%s' flag" ,
63+ fName , mainFlag )
64+ }
65+ }
66+ return nil
67+ }
68+
5869func getUserIDbyUsername (username string ) (int , error ) {
5970 userInfo , err := getUserByUsername (username )
6071 if err != nil {
You can’t perform that action at this time.
0 commit comments