Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Latest commit

 

History

History
116 lines (74 loc) · 1.99 KB

CONFIGURATION.md

File metadata and controls

116 lines (74 loc) · 1.99 KB

Configuration

dest

generated code file path.

formatters

formatters is the list of command to format generated code file. For example,

formatters:
- gofmt -l -s -w

the target file path is added to each command.

default

default defines the parameter's default configuration. If each param's configuration overwrites the default configuration. The default configuration is optional.

  • default.env.bind
  • default.env.prefix
  • default.flag.bind

params[].name

param.name is the viper key.

params[].type

param.type is the paramter's type. If it is not set, the type is inferred using the default value. For example, if param.default is 10, param.type is inferred as "int".

params[].description

params[].default

params[].default is the default value of the parameter.

viper.SetDefault(portKey, 3000)
pflag.IntP("port", "p", 3000, "app port number")

params[].flag

params[].env

bind

env.bind

viper.BindEnv(portKey, "SAMPLE_PORT")

flag.bind

pflag.IntP("port", "p", 3000, "app port number")
viper.BindPFlag(portKey, pflag.Lookup("port"))
pflag.Parse()

Each param's end.bind and flag.bind is true if each param's other configuration such as env.prefix defines explicitly.

flag.description

flag.description is the description of the flag. If it is not set, params[].description is used.

pflag.IntP("port", "p", 3000, "app port number")

flag.name

flag.name is the flag name.

pflag.IntP("port", "p", 3000, "app port number")

flag.short

Optional.

If flag.short is set,

pflag.IntP("port", "p", 3000, "app port number")

otherwise

pflag.Int("port", 3000, "app port number")

env.name

env.name is the binded environment variable name. The default value is {{env.prefix}}{{param.name}} .

env.prefix

env.prefix is the prefix of environment variable name. If env.name is set, env.prefix is ignored.