alecthomas / kong

Kong is a command-line parser for Go
MIT License
2.15k stars 140 forks source link

Placeholder tag documentation doesn't mention it is only used for flags #447

Closed jeralm closed 3 months ago

jeralm commented 3 months ago

The documentation is not clear on what the placeholder tag actually does. Digging in the code, I found that it is (I think) only ever used to print help for flags, not cmds or positional args.

This command struct:

type FooCmd struct {
  barArg string `arg:"" name:"bar-arg-name" placeholder:"disregarded_placeholder" help:"Help text for barArg."`
  bazFlag string `placeholder:"<PLACEHOLDER>" help:"Help text for bazFlag."`
}

gives the following help:

$ foo --help

Usage: foo <bar-arg-name>

[...]

Arguments:
  <bar-arg-name>    Help text for barArg.

Flags:
      --baz-flag=<PLACEHOLDER>    Help text for bazFlag.

I was initially under the impression that <bar-arg-name> would actually display as <disregarded_placeholder> instead.

I'm not sure if this is simply a matter of updating the README.md or if this should also be documented in the go docs.

alecthomas commented 3 months ago

The README should be updated to reflect that it is only used for flags.

jeralm commented 3 months ago

Thanks, making a quick PR