MCPcopy
hub / github.com/spf13/cobra / MarkFlagRequired

Function MarkFlagRequired

shell_completions.go:38–40  ·  view source on GitHub ↗

MarkFlagRequired instructs the various shell completion implementations to prioritize the named flag when performing completion, and causes your command to report an error if invoked without the flag.

(flags *pflag.FlagSet, name string)

Source from the content-addressed store, hash-verified

36// prioritize the named flag when performing completion,
37// and causes your command to report an error if invoked without the flag.
38func MarkFlagRequired(flags *pflag.FlagSet, name string) error {
39 return flags.SetAnnotation(name, BashCompOneRequiredFlag, []string{"true"})
40}
41
42// MarkFlagFilename instructs the various shell completion implementations to
43// limit completions for the named flag to the specified file extensions.

Callers 2

MarkFlagRequiredMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected