Don't display deprecated flags in bash completions
This commit is contained in:
@ -158,3 +158,23 @@ func TestBashCompletionHiddenFlag(t *testing.T) {
|
||||
t.Error("expected completion to not include %q flag: Got %v", flagName, bashCompletion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBashCompletionDeprecatedFlag(t *testing.T) {
|
||||
var cmdTrue = &Command{
|
||||
Use: "does nothing",
|
||||
Run: func(cmd *Command, args []string) {},
|
||||
}
|
||||
|
||||
const flagName = "deprecated-foo-bar-baz"
|
||||
|
||||
var flagValue bool
|
||||
cmdTrue.Flags().BoolVar(&flagValue, flagName, false, "hidden flag")
|
||||
cmdTrue.Flags().MarkDeprecated(flagName, "use --does-not-exist instead")
|
||||
|
||||
out := new(bytes.Buffer)
|
||||
cmdTrue.GenBashCompletion(out)
|
||||
bashCompletion := out.String()
|
||||
if strings.Contains(bashCompletion, flagName) {
|
||||
t.Errorf("expected completion to not include %q flag: Got %v", flagName, bashCompletion)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user