File: commandlineCVFull.tmpl

package info (click to toggle)
easygen 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 848 kB
  • sloc: sh: 14; makefile: 13
file content (33 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
func init() {

  viper.SetEnvPrefix("{{.CmdPrefix}}")
  viper.AutomaticEnv()

  /*

    When AutomaticEnv called, Viper will check for an environment variable any
    time a viper.Get request is made. It will apply the following rules. It
    will check for a environment variable with a name matching the key
    uppercased and prefixed with the EnvPrefix if set.

  */

  flags := {{.CmdMain}}.Flags()
{{range .Options}}
  flags.{{.Type}}("{{.Name}}", {{.Value}}, "{{.Usage}}")
  viper.BindPFlag("{{.Name}}", flags.Lookup("{{.Name}}"))
{{end}}
  // Viper supports reading from yaml, toml and/or json files. Viper can
  // search multiple paths. Paths will be searched in the order they are
  // provided. Searches stopped once Config File found.

  viper.SetConfigName("{{.ConfigName}}") // name of config file (without extension)
{{range .ConfigPath}}
  viper.AddConfigPath("{{.}}"){{end}}

  err := viper.ReadInConfig()
  if err != nil {
    println("No config file found. Using built-in defaults.")
  }

}