clagraff / argparse

A Golang argument parser for command line arguments.
MIT License
24 stars 4 forks source link

added env var defaults #32

Closed clagraff closed 7 years ago

clagraff commented 7 years ago

This PR adds the ability to use environmental variable values as stand-in default values for options. It works by specifying the env var name as the default for an option.

For example, if you export a env variable:

> export MY_BOOL="false"

... you can then use the value of that variable during argument parsing by specifiny the env var name as the Default value:

...
option.Default("$MY_BOOL")
...

Signed-off-by: Curtis La Graff curtis@amberengine.com

clagraff commented 7 years ago

Addresses: https://github.com/clagraff/argparse/issues/25