diff --git a/README.md b/README.md index a36ab21..28e5c90 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,13 @@ Usage: confpress [OPTIONS] Application Options: - -v, --version Show version -d, --debug Log debug messages - -t, --template= Input template file (- for stdin) (default: -) - -o, --output= Output file (- for stdout) (default: -) - -i, --input= Input variable file(s) -e, --env_prefix= Environment variables prefix (default: CONF_) + -i, --input= Input variable file(s) + -m, --missing Allow missing keys + -o, --output= Output file (- for stdout) (default: -) + -t, --template= Input template file (- for stdin) (default: -) + -v, --version Show version Help Options: -h, --help Show this help message @@ -24,5 +25,5 @@ Help Options: ### Examples - **Reading a variable from yaml/json as shell env variable:** - + `MY_VAR=$(echo "{{ .my_variable }}" | confpress -i variables.yaml)` diff --git a/confpress.go b/confpress.go index f639a4b..77abeca 100644 --- a/confpress.go +++ b/confpress.go @@ -13,17 +13,16 @@ import ( ) type Options struct { - Version bool `short:"v" long:"version" description:"Show version"` Debug bool `short:"d" long:"debug" description:"Log debug messages"` - TemplatePath string `short:"t" long:"template" description:"Input template file (- for stdin)" default:"-"` - OutputPath string `short:"o" long:"output" description:"Output file (- for stdout)" default:"-"` - - InputPaths []string `short:"i" long:"input" description:"Input variable file(s)"` - EnvPrefix string `short:"e" long:"env_prefix" description:"Environment variables prefix" default:"CONF_"` + InputPaths []string `short:"i" long:"input" description:"Input variable file(s)"` + Missing bool `short:"m" long:"missing" description:"Allow missing keys"` + OutputPath string `short:"o" long:"output" description:"Output file (- for stdout)" default:"-"` + TemplatePath string `short:"t" long:"template" description:"Input template file (- for stdin)" default:"-"` + Version bool `short:"v" long:"version" description:"Show version"` } -const version=`0.0.1` +const version=`0.1.0` var opts Options var parser = flags.NewParser(&opts, flags.Default) var log = logging.MustGetLogger("default") @@ -84,8 +83,10 @@ func main() { os.Exit(1) } - // err on missing keys - temp.Option("missingkey=error") + if ! opts.Missing { + // err on missing keys + temp.Option("missingkey=error") + } log.Infof("Opening output file: '%s'", opts.OutputPath) outFile, err := createStream(opts.OutputPath)