File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,7 +126,10 @@ func NewRootCommand(
126126 Long : "LaunchDarkly CLI to control your feature flags" ,
127127 Version : version ,
128128 PersistentPreRun : func (cmd * cobra.Command , args []string ) {
129- // disable required flags when running certain commands
129+ // Skip the global --access-token required-flag check for commands
130+ // that don't need an API token. We clear the annotation on the
131+ // specific flag instead of setting DisableFlagParsing, which would
132+ // also suppress validation for the subcommand's own required flags.
130133 for _ , name := range []string {
131134 "completion" ,
132135 "config" ,
@@ -135,14 +138,13 @@ func NewRootCommand(
135138 "signup" ,
136139 "whoami" ,
137140 } {
138- if cmd .HasParent () && cmd .Parent ().Name () == name {
139- cmd .DisableFlagParsing = true
140- }
141- if cmd . Name () == name {
142- cmd . DisableFlagParsing = true
141+ if cmd .Name () == name || ( cmd . HasParent () && cmd .Parent ().Name () == name ) {
142+ if f := cmd .Flags (). Lookup ( cliflags . AccessTokenFlag ); f != nil {
143+ delete ( f . Annotations , cobra . BashCompOneRequiredFlag )
144+ }
145+ break
143146 }
144147 }
145-
146148 },
147149 Annotations : make (map [string ]string ),
148150 // Handle errors differently based on type.
You can’t perform that action at this time.
0 commit comments