Skip to content

Commit

Permalink
fixup! Use built-in mechanism to handle mutually exclusive params
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Sul <[email protected]>
  • Loading branch information
mike-sul committed Feb 6, 2024
1 parent b0a1091 commit 143871c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions subcommands/targets/offline-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func init() {
"Skip fetching Target Apps")
offlineUpdateCmd.Flags().BoolVarP(&ouAllowMultipleTargets, "allow-multiple-targets", "", false,
"Allow multiple targets to be stored in the same <dst> directory")
offlineUpdateCmd.MarkFlagsMutuallyExclusive("tag", "wave")
offlineUpdateCmd.MarkFlagsMutuallyExclusive("prod", "wave")
}

func doOfflineUpdate(cmd *cobra.Command, args []string) {
Expand All @@ -81,13 +83,7 @@ func doOfflineUpdate(cmd *cobra.Command, args []string) {
dstDir := args[1]

if len(ouTag) == 0 && len(ouWave) == 0 {
subcommands.DieNotNil(errors.New("one of the mandatory parameters `--tag` or `--wave` should be specified"))
}
if len(ouTag) > 0 && len(ouWave) > 0 {
subcommands.DieNotNil(errors.New("either `--tag` or `--wave` should be specified exclusively"))
}
if len(ouWave) > 0 && ouProd {
subcommands.DieNotNil(errors.New("`the --prod` flag is redundant if the `--wave` parameter is specified"))
subcommands.DieNotNil(errors.New("Either `--tag` or `--wave` should be specified"))
}

var targetCustomData *tuf.FileMeta
Expand Down

0 comments on commit 143871c

Please sign in to comment.