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

Function TestHiddenFlagUsage

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

Source from the content-addressed store, hash-verified

1256}
1257
1258func TestHiddenFlagUsage(t *testing.T) {
1259 f := NewFlagSet("bob", ContinueOnError)
1260 f.Bool("secretFlag", true, "shhh")
1261 f.MarkHidden("secretFlag")
1262
1263 args := []string{"--secretFlag"}
1264 out, err := parseReturnStderr(t, f, args)
1265 if err != nil {
1266 t.Fatal("expected no error; got ", err)
1267 }
1268
1269 if strings.Contains(out, "shhh") {
1270 t.Errorf("usage message printed when using a hidden flag!")
1271 }
1272}
1273
1274const defaultOutput = ` --A for bootstrapping, allow 'any' type
1275 --Alongflagname disable bounds checking

Callers

nothing calls this directly

Calls 4

BoolMethod · 0.95
MarkHiddenMethod · 0.95
NewFlagSetFunction · 0.85
parseReturnStderrFunction · 0.85

Tested by

no test coverage detected