MCPcopy Create free account
hub / github.com/alecthomas/kong / TestMultipleEnvarAutoHelpWithEnvPrefix

Function TestMultipleEnvarAutoHelpWithEnvPrefix

help_test.go:503–517  ·  view source on GitHub ↗

nolint:dupl // false positive

(t *testing.T)

Source from the content-addressed store, hash-verified

501
502//nolint:dupl // false positive
503func TestMultipleEnvarAutoHelpWithEnvPrefix(t *testing.T) {
504 type Anonymous struct {
505 Flag string `env:"FLAG1,FLAG2" help:"A flag."`
506 Other string `help:"A different flag."`
507 }
508 var cli struct {
509 Anonymous `envprefix:"ANON_"`
510 }
511 w := &strings.Builder{}
512 p := mustNew(t, &cli, kong.Writers(w, w), kong.Exit(func(int) {}))
513 _, err := p.Parse([]string{"--help"})
514 assert.NoError(t, err)
515 assert.Contains(t, w.String(), "A flag ($ANON_FLAG1, $ANON_FLAG2).")
516 assert.Contains(t, w.String(), "A different flag.")
517}
518
519//nolint:dupl // false positive
520func TestCustomValueFormatter(t *testing.T) {

Callers

nothing calls this directly

Calls 5

WritersFunction · 0.92
ExitFunction · 0.92
mustNewFunction · 0.85
ParseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected