MCPcopy
hub / github.com/spf13/pflag / TestDeprecatedFlagShorthandInDocs

Function TestDeprecatedFlagShorthandInDocs

flag_test.go:1141–1154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1139}
1140
1141func TestDeprecatedFlagShorthandInDocs(t *testing.T) {
1142 f := NewFlagSet("bob", ContinueOnError)
1143 name := "noshorthandflag"
1144 f.BoolP(name, "n", true, "always true")
1145 f.MarkShorthandDeprecated("noshorthandflag", fmt.Sprintf("use --%s instead", name))
1146
1147 out := new(bytes.Buffer)
1148 f.SetOutput(out)
1149 f.PrintDefaults()
1150
1151 if strings.Contains(out.String(), "-n,") {
1152 t.Errorf("found deprecated flag shorthand in usage!")
1153 }
1154}
1155
1156func parseReturnStderr(t *testing.T, f *FlagSet, args []string) (string, error) {
1157 oldStderr := os.Stderr

Callers

nothing calls this directly

Calls 6

BoolPMethod · 0.95
SetOutputMethod · 0.95
PrintDefaultsMethod · 0.95
NewFlagSetFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected