peterbourgon / ff

Flags-first package for configuration
Apache License 2.0
1.37k stars 59 forks source link

parse: add env var name to usage text #65

Closed edev0 closed 4 years ago

edev0 commented 4 years ago

Thanks for this great library !

This PR automatically adds environment variable names to each flag's usage text.

For example, a definition such as:

var (
    port  = fs.Int("port", 8080, "listen port for server")
    debug = fs.Bool("debug", false, "log debug information")
)
ff.Parse(fs, os.Args[1:], ff.WithEnvVarNoPrefix())

would result in the following usage text:

Usage of myservice:
  -debug
        log debug information (also via env var DEBUG)
  -port int
        listen port for server (also via env var PORT) (default 8080)

Also fixed some small typos.

peterbourgon commented 4 years ago

Sorry, I don't want this package to mutate the provided FlagSet.

edev0 commented 4 years ago

Understood, thanks !