diff --git a/cmd/create.go b/cmd/create.go index 17676f5..8226cbb 100644 --- a/cmd/create.go +++ b/cmd/create.go @@ -48,6 +48,9 @@ func NewCreateCommand(parentCmd *cobra.Command) func() { var ifAliasExists = "" var ifAliasDoesNotExist = "" var skipAliases = false + var repeat uint32 = 1 + var repeatDelay uint32 = 100 + var ignoreErrors = false resetFunc := func() { autoFillOnCreate = false @@ -60,6 +63,9 @@ func NewCreateCommand(parentCmd *cobra.Command) func() { overrides.QueryParameters = nil skipAliases = false compactOutput = false + repeat = 1 + repeatDelay = 100 + ignoreErrors = false } for _, resource := range resources.GetPluralResources() { @@ -78,71 +84,74 @@ func NewCreateCommand(parentCmd *cobra.Command) func() { Example: GetCreateExample(resource), Args: GetArgFunctionForCreate(resource), RunE: func(cmd *cobra.Command, args []string) error { - - if ifAliasExists != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") - - if aliasId == ifAliasExists { - // If the aliasId is the same as requested, it means an alias did not exist. - log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) - return nil + c := func(cmd *cobra.Command, args []string) error { + if ifAliasExists != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") + + if aliasId == ifAliasExists { + // If the aliasId is the same as requested, it means an alias did not exist. + log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) + return nil + } } - } - if ifAliasDoesNotExist != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") + if ifAliasDoesNotExist != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") - if aliasId != ifAliasDoesNotExist { - // If the aliasId is different than the request then it does exist. - log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) - return nil + if aliasId != ifAliasDoesNotExist { + // If the aliasId is different than the request then it does exist. + log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) + return nil + } } - } - body, err := createInternal(context.Background(), overrides, append([]string{resourceName}, args...), autoFillOnCreate, setAlias, skipAliases) - - if err != nil { - return err - } - - if outputJq != "" { - output, err := json.RunJQOnStringWithArray(outputJq, body) + body, err := createInternal(context.Background(), overrides, append([]string{resourceName}, args...), autoFillOnCreate, setAlias, skipAliases) if err != nil { return err } - for _, outputLine := range output { - outputJson, err := gojson.Marshal(outputLine) + if outputJq != "" { + output, err := json.RunJQOnStringWithArray(outputJq, body) if err != nil { return err } - err = json.PrintJson(string(outputJson)) + for _, outputLine := range output { + outputJson, err := gojson.Marshal(outputLine) - if err != nil { - return err + if err != nil { + return err + } + + err = json.PrintJson(string(outputJson)) + + if err != nil { + return err + } } - } - return nil - } + return nil + } - if noBodyPrint { - return nil - } else { - if compactOutput { - body, err = json.Compact(body) + if noBodyPrint { + return nil + } else { + if compactOutput { + body, err = json.Compact(body) - if err != nil { - return err + if err != nil { + return err + } } + + return json.PrintJson(body) } - return json.PrintJson(body) } + return repeater(c, repeat, repeatDelay, cmd, args, ignoreErrors) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -218,11 +227,15 @@ func NewCreateCommand(parentCmd *cobra.Command) func() { createCmd.PersistentFlags().StringSliceVarP(&overrides.QueryParameters, "query-parameters", "q", []string{}, "Pass in key=value an they will be added as query parameters") createCmd.PersistentFlags().StringVarP(&outputJq, "output-jq", "", "", "A jq expression, if set we will restrict output to only this") createCmd.PersistentFlags().BoolVarP(&compactOutput, "compact", "", false, "Hides some of the boiler plate keys and empty fields, etc...") + createCmd.PersistentFlags().BoolVarP(&ignoreErrors, "ignore-errors", "", false, "Don't return non zero on an error") createCmd.PersistentFlags().StringVarP(&setAlias, "save-as-alias", "", "", "A name to save the created resource as") createCmd.PersistentFlags().StringVarP(&ifAliasExists, "if-alias-exists", "", "", "If the alias exists we will run this command, otherwise exit with no error") createCmd.PersistentFlags().StringVarP(&ifAliasDoesNotExist, "if-alias-does-not-exist", "", "", "If the alias does not exist we will run this command, otherwise exit with no error") createCmd.PersistentFlags().BoolVarP(&skipAliases, "skip-alias-processing", "", false, "if set, we don't process the response for aliases") createCmd.MarkFlagsMutuallyExclusive("if-alias-exists", "if-alias-does-not-exist") + createCmd.PersistentFlags().Uint32VarP(&repeat, "repeat", "", 1, "Number of times to repeat the command") + createCmd.PersistentFlags().Uint32VarP(&repeatDelay, "repeat-delay", "", 100, "Delay (in ms) between repeats") + _ = createCmd.RegisterFlagCompletionFunc("output-jq", jqCompletionFunc) return resetFunc diff --git a/cmd/delete.go b/cmd/delete.go index 7d77ea0..5f04fd5 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -41,6 +41,10 @@ func NewDeleteCommand(parentCmd *cobra.Command) func() { var allow404 = false var ifAliasExists = "" var ifAliasDoesNotExist = "" + var repeat uint32 = 1 + var repeatDelay uint32 = 100 + var ignoreErrors = false + var noBodyPrint = false resetFunc := func() { overrides.QueryParameters = nil @@ -48,6 +52,10 @@ func NewDeleteCommand(parentCmd *cobra.Command) func() { allow404 = false ifAliasExists = "" ifAliasDoesNotExist = "" + noBodyPrint = false + repeat = 1 + repeatDelay = 100 + ignoreErrors = false } for _, resource := range resources.GetPluralResources() { @@ -65,37 +73,46 @@ func NewDeleteCommand(parentCmd *cobra.Command) func() { Example: GetDeleteExample(resource), Args: GetArgFunctionForDelete(resource), RunE: func(cmd *cobra.Command, args []string) error { + c := func(cmd *cobra.Command, args []string) error { + if ifAliasExists != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") + + if aliasId == ifAliasExists { + // If the aliasId is the same as requested, it means an alias did not exist. + log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) + return nil + } + } - if ifAliasExists != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") + if ifAliasDoesNotExist != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") - if aliasId == ifAliasExists { - // If the aliasId is the same as requested, it means an alias did not exist. - log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) - return nil + if aliasId != ifAliasDoesNotExist { + // If the aliasId is different than the request then it does exist. + log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) + return nil + } } - } - if ifAliasDoesNotExist != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") + body, err := deleteInternal(context.Background(), overrides, allow404, append([]string{resourceName}, args...)) - if aliasId != ifAliasDoesNotExist { - // If the aliasId is different than the request then it does exist. - log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) - return nil + if err != nil { + if body != "" { + if !noBodyPrint { + json.PrintJson(body) + } + } + return err } - } - - body, err := deleteInternal(context.Background(), overrides, allow404, append([]string{resourceName}, args...)) - if err != nil { - if body != "" { - json.PrintJson(body) + if noBodyPrint { + return nil + } else { + return json.PrintJson(body) } - return err } - return json.PrintJson(body) + return repeater(c, repeat, repeatDelay, cmd, args, ignoreErrors) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -165,7 +182,12 @@ func NewDeleteCommand(parentCmd *cobra.Command) func() { deleteCmd.PersistentFlags().BoolVar(&allow404, "allow-404", allow404, "If set 404's will not be treated as errors") deleteCmd.PersistentFlags().StringVarP(&ifAliasExists, "if-alias-exists", "", "", "If the alias exists we will run this command, otherwise exit with no error") deleteCmd.PersistentFlags().StringVarP(&ifAliasDoesNotExist, "if-alias-does-not-exist", "", "", "If the alias does not exist we will run this command, otherwise exit with no error") + deleteCmd.PersistentFlags().BoolVarP(&noBodyPrint, "silent", "s", false, "Don't print the body on success") deleteCmd.MarkFlagsMutuallyExclusive("if-alias-exists", "if-alias-does-not-exist") + deleteCmd.PersistentFlags().Uint32VarP(&repeat, "repeat", "", 1, "Number of times to repeat the command") + deleteCmd.PersistentFlags().Uint32VarP(&repeatDelay, "repeat-delay", "", 100, "Delay (in ms) between repeats") + deleteCmd.PersistentFlags().BoolVarP(&ignoreErrors, "ignore-errors", "", false, "Don't return non zero on an error") + parentCmd.AddCommand(deleteCmd) return resetFunc diff --git a/cmd/get.go b/cmd/get.go index 1efcb00..d39d9e8 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -37,6 +37,9 @@ func NewGetCommand(parentCmd *cobra.Command) func() { var ifAliasExists = "" var ifAliasDoesNotExist = "" var skipAliases = false + var repeat uint32 = 1 + var repeatDelay uint32 = 100 + var ignoreErrors = false resetFunc := func() { overrides.QueryParameters = nil @@ -49,6 +52,9 @@ func NewGetCommand(parentCmd *cobra.Command) func() { ifAliasExists = "" ifAliasDoesNotExist = "" skipAliases = false + repeat = 1 + repeatDelay = 100 + ignoreErrors = false } @@ -112,109 +118,114 @@ func NewGetCommand(parentCmd *cobra.Command) func() { Args: GetArgFunctionForUrl(resourceName, resourceUrl), RunE: func(cmd *cobra.Command, args []string) error { - if ifAliasExists != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") + c := func(cmd *cobra.Command, args []string) error { - if aliasId == ifAliasExists { - // If the aliasId is the same as requested, it means an alias did not exist. - log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) - return nil + if ifAliasExists != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") + + if aliasId == ifAliasExists { + // If the aliasId is the same as requested, it means an alias did not exist. + log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) + return nil + } } - } - if ifAliasDoesNotExist != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") + if ifAliasDoesNotExist != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") - if aliasId != ifAliasDoesNotExist { - // If the aliasId is different than the request then it does exist. - log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) - return nil + if aliasId != ifAliasDoesNotExist { + // If the aliasId is different than the request then it does exist. + log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) + return nil + } } - } - var body string - var err error - if retryWhileJQMaxAttempts == 0 { - return fmt.Errorf("--retry-while-jq-max-attempts must be greater than 0") - } + var body string + var err error + if retryWhileJQMaxAttempts == 0 { + return fmt.Errorf("--retry-while-jq-max-attempts must be greater than 0") + } - retriesFailedError := fmt.Errorf("Maximum number of retries hit %d and condition [%s] always true", retryWhileJQMaxAttempts, retryWhileJQ) + retriesFailedError := fmt.Errorf("Maximum number of retries hit %d and condition [%s] always true", retryWhileJQMaxAttempts, retryWhileJQ) - for attempt := uint16(0); attempt < retryWhileJQMaxAttempts; attempt++ { - body, err = getInternal(context.Background(), overrides, append([]string{resourceName}, args...), skipAliases) - if retryWhileJQ == "" { - retriesFailedError = nil - break - } + for attempt := uint16(0); attempt < retryWhileJQMaxAttempts; attempt++ { + body, err = getInternal(context.Background(), overrides, append([]string{resourceName}, args...), skipAliases) + if retryWhileJQ == "" { + retriesFailedError = nil + break + } - resultOfRetryWhileJQ, err := json.RunJQOnStringWithArray(retryWhileJQ, body) + resultOfRetryWhileJQ, err := json.RunJQOnStringWithArray(retryWhileJQ, body) - if err != nil { - break - } + if err != nil { + break + } - if len(resultOfRetryWhileJQ) > 0 { - if result, ok := resultOfRetryWhileJQ[0].(bool); ok { - if result { - time.Sleep(3 * time.Second) - continue + if len(resultOfRetryWhileJQ) > 0 { + if result, ok := resultOfRetryWhileJQ[0].(bool); ok { + if result { + time.Sleep(3 * time.Second) + continue + } } } - } - - log.Infof("Result of JQ [%s] was: %v, retries complete", retryWhileJQ, resultOfRetryWhileJQ) - retriesFailedError = nil - break - } - - if err != nil { - return err - } + log.Infof("Result of JQ [%s] was: %v, retries complete", retryWhileJQ, resultOfRetryWhileJQ) + retriesFailedError = nil + break - if outputJq != "" { - output, err := json.RunJQOnStringWithArray(outputJq, body) + } if err != nil { return err } - for _, outputLine := range output { - outputJson, err := gojson.Marshal(outputLine) + + if outputJq != "" { + output, err := json.RunJQOnStringWithArray(outputJq, body) if err != nil { return err } + for _, outputLine := range output { + outputJson, err := gojson.Marshal(outputLine) + + if err != nil { + return err + } - err = json.PrintJson(string(outputJson)) + err = json.PrintJson(string(outputJson)) - if err != nil { - return err + if err != nil { + return err + } } - } - return retriesFailedError - } + return retriesFailedError + } - if noBodyPrint { - return retriesFailedError - } else { - if compactOutput { - body, err = json.Compact(body) + if noBodyPrint { + return retriesFailedError + } else { + if compactOutput { + body, err = json.Compact(body) - if err != nil { - return err + if err != nil { + return err + } } - } - printError := json.PrintJson(body) + printError := json.PrintJson(body) - if retriesFailedError != nil { - return retriesFailedError - } + if retriesFailedError != nil { + return retriesFailedError + } - return printError + return printError + } } + return repeater(c, repeat, repeatDelay, cmd, args, ignoreErrors) + }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -278,12 +289,16 @@ func NewGetCommand(parentCmd *cobra.Command) func() { getCmd.PersistentFlags().StringSliceVarP(&overrides.QueryParameters, "query-parameters", "q", []string{}, "Pass in key=value an they will be added as query parameters") getCmd.PersistentFlags().StringVarP(&outputJq, "output-jq", "", "", "A jq expression, if set we will restrict output to only this") getCmd.PersistentFlags().BoolVarP(&compactOutput, "compact", "", false, "Hides some of the boiler plate keys and empty fields, etc...") + getCmd.PersistentFlags().BoolVarP(&ignoreErrors, "ignore-errors", "", false, "Don't return non zero on an error") getCmd.PersistentFlags().StringVarP(&retryWhileJQ, "retry-while-jq", "", "", "A jq expression, if set and returns true we will retry the get command (see manual for examples)") getCmd.PersistentFlags().Uint16VarP(&retryWhileJQMaxAttempts, "retry-while-jq-max-attempts", "", 1200, "The maximum number of attempts we will retry with jq") getCmd.PersistentFlags().StringVarP(&ifAliasExists, "if-alias-exists", "", "", "If the alias exists we will run this command, otherwise exit with no error") getCmd.PersistentFlags().StringVarP(&ifAliasDoesNotExist, "if-alias-does-not-exist", "", "", "If the alias does not exist we will run this command, otherwise exit with no error") getCmd.PersistentFlags().BoolVarP(&skipAliases, "skip-alias-processing", "", false, "if set, we don't process the response for aliases") getCmd.MarkFlagsMutuallyExclusive("if-alias-exists", "if-alias-does-not-exist") + getCmd.PersistentFlags().Uint32VarP(&repeat, "repeat", "", 1, "Number of times to repeat the command") + getCmd.PersistentFlags().Uint32VarP(&repeatDelay, "repeat-delay", "", 100, "Delay (in ms) between repeats") + _ = getCmd.RegisterFlagCompletionFunc("output-jq", jqCompletionFunc) parentCmd.AddCommand(getCmd) diff --git a/cmd/repeater.go b/cmd/repeater.go new file mode 100644 index 0000000..9005075 --- /dev/null +++ b/cmd/repeater.go @@ -0,0 +1,33 @@ +package cmd + +import ( + "github.com/elasticpath/epcc-cli/external/shutdown" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "time" +) + +func repeater(c func(*cobra.Command, []string) error, repeat, repeatDelay uint32, cmd *cobra.Command, args []string, ignoreErrors bool) error { + for i := 0; i < int(repeat); i++ { + err := c(cmd, args) + + if err != nil { + + if ignoreErrors { + log.Debugf("Ignored error %v", ignoreErrors) + } else { + return err + } + } + + if i < int(repeat)-1 { + time.Sleep(time.Duration(repeatDelay) * time.Millisecond) + } + + if shutdown.ShutdownFlag.Load() { + return nil + } + } + + return nil +} diff --git a/cmd/update.go b/cmd/update.go index b5a6c45..2c77fde 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -30,6 +30,9 @@ func NewUpdateCommand(parentCmd *cobra.Command) func() { var ifAliasExists = "" var ifAliasDoesNotExist = "" var skipAliases = false + var repeat uint32 = 1 + var repeatDelay uint32 = 100 + var ignoreErrors = false resetFunc := func() { overrides.QueryParameters = nil @@ -40,6 +43,9 @@ func NewUpdateCommand(parentCmd *cobra.Command) func() { ifAliasExists = "" ifAliasDoesNotExist = "" skipAliases = false + repeat = 1 + repeatDelay = 100 + ignoreErrors = false } var updateCmd = &cobra.Command{ @@ -68,71 +74,73 @@ func NewUpdateCommand(parentCmd *cobra.Command) func() { Example: GetUpdateExample(resource), Args: GetArgFunctionForUpdate(resource), RunE: func(cmd *cobra.Command, args []string) error { - - if ifAliasExists != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") - - if aliasId == ifAliasExists { - // If the aliasId is the same as requested, it means an alias did not exist. - log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) - return nil + c := func(cmd *cobra.Command, args []string) error { + if ifAliasExists != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasExists, "id") + + if aliasId == ifAliasExists { + // If the aliasId is the same as requested, it means an alias did not exist. + log.Infof("Alias [%s] does not exist, not continuing run", ifAliasExists) + return nil + } } - } - if ifAliasDoesNotExist != "" { - aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") + if ifAliasDoesNotExist != "" { + aliasId := aliases.ResolveAliasValuesOrReturnIdentity(resource.JsonApiType, resource.AlternateJsonApiTypesForAliases, ifAliasDoesNotExist, "id") - if aliasId != ifAliasDoesNotExist { - // If the aliasId is different than the request then it does exist. - log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) - return nil + if aliasId != ifAliasDoesNotExist { + // If the aliasId is different than the request then it does exist. + log.Infof("Alias [%s] does exist (value: %s), not continuing run", ifAliasDoesNotExist, aliasId) + return nil + } } - } - - body, err := updateInternal(context.Background(), overrides, skipAliases, append([]string{resourceName}, args...)) - - if err != nil { - return err - } - if outputJq != "" { - output, err := json.RunJQOnStringWithArray(outputJq, body) + body, err := updateInternal(context.Background(), overrides, skipAliases, append([]string{resourceName}, args...)) if err != nil { return err } - for _, outputLine := range output { - outputJson, err := gojson.Marshal(outputLine) + if outputJq != "" { + output, err := json.RunJQOnStringWithArray(outputJq, body) if err != nil { return err } - err = json.PrintJson(string(outputJson)) + for _, outputLine := range output { + outputJson, err := gojson.Marshal(outputLine) - if err != nil { - return err + if err != nil { + return err + } + + err = json.PrintJson(string(outputJson)) + + if err != nil { + return err + } } - } - return nil - } + return nil + } - if noBodyPrint { - return nil - } else { - if compactOutput { - body, err = json.Compact(body) + if noBodyPrint { + return nil + } else { + if compactOutput { + body, err = json.Compact(body) - if err != nil { - return err + if err != nil { + return err + } } - } - return json.PrintJson(body) + return json.PrintJson(body) + } } + return repeater(c, repeat, repeatDelay, cmd, args, ignoreErrors) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -190,11 +198,15 @@ func NewUpdateCommand(parentCmd *cobra.Command) func() { updateCmd.PersistentFlags().BoolVarP(&noBodyPrint, "silent", "s", false, "Don't print the body on success") updateCmd.PersistentFlags().StringVarP(&outputJq, "output-jq", "", "", "A jq expression, if set we will restrict output to only this") updateCmd.PersistentFlags().BoolVarP(&compactOutput, "compact", "", false, "Hides some of the boiler plate keys and empty fields, etc...") + updateCmd.PersistentFlags().BoolVarP(&ignoreErrors, "ignore-errors", "", false, "Don't return non zero on an error") updateCmd.PersistentFlags().StringVarP(&ifAliasExists, "if-alias-exists", "", "", "If the alias exists we will run this command, otherwise exit with no error") updateCmd.PersistentFlags().StringVarP(&ifAliasDoesNotExist, "if-alias-does-not-exist", "", "", "If the alias does not exist we will run this command, otherwise exit with no error") updateCmd.MarkFlagsMutuallyExclusive("if-alias-exists", "if-alias-does-not-exist") updateCmd.PersistentFlags().BoolVarP(&skipAliases, "skip-alias-processing", "", false, "if set, we don't process the response for aliases") _ = updateCmd.RegisterFlagCompletionFunc("output-jq", jqCompletionFunc) + updateCmd.PersistentFlags().Uint32VarP(&repeat, "repeat", "", 1, "Number of times to repeat the command") + updateCmd.PersistentFlags().Uint32VarP(&repeatDelay, "repeat-delay", "", 100, "Delay (in ms) between repeats") + parentCmd.AddCommand(updateCmd) return resetFunc