diff --git a/internal/commands/root.go b/internal/commands/root.go index 453070073..03be18054 100644 --- a/internal/commands/root.go +++ b/internal/commands/root.go @@ -123,6 +123,13 @@ func NewAstCLI( if err != nil { return err } + if cmd.Flags().Changed(params.AccessKeyIDFlag) || cmd.Flags().Changed(params.AccessKeySecretFlag) { + viper.Set(params.AstAPIKey, "") + } + if cmd.Flags().Changed(params.AstAPIKeyFlag) { + viper.Set(params.AccessKeyIDConfigKey, "") + viper.Set(params.AccessKeySecretConfigKey, "") + } // Need to check the __complete command to allow correct behavior of the autocomplete if len(args) > 0 && cmd.Name() != params.Help && cmd.Name() != "__complete" { _ = cmd.Help()