Skip to content
Myr

add a helper to annotate a flag as 'required' by a command

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Eric Paris · committed by Eric Paris · parent 9b2e682 · Browse files · 1 file+13 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−0 removed

  • other:+13 added−0 removed

1 file+13 added−0 removed

modified:bash_completions.go+13 added
326 unmodified lines
327 return err328 }329 return nil330}331332func (cmd *Command) MarkFlagRequired(name string) {333 flag := cmd.Flags().Lookup(name)334 if flag == nil {335 return336 }337 if flag.Annotations == nil {338 flag.Annotations = make(map[string][]string)339 }340 annotation := make([]string, 1)341 annotation[0] = "true"342 flag.Annotations[BashCompOneRequiredFlag] = annotation343}