Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "envtpl", Short: "Render go templates from environment variables", Long: `Render go templates from environment variables.`, Run: func(cmd *cobra.Command, args []string) { // load template; if an argument is not specified, default to stdin var t *template.Template if len(args) > 0 { t, err = parseFiles(args...) checkError(err) } else { bytes, err := ioutil.ReadAll(os.Stdin) checkError(err) t, err = parse(string(bytes)) checkError(err) } env := readEnv() // get writer for rendered output; if an output file is not // specified, default to stdout var w io.Writer if len(output) > 0 { f, err := os.Create(output) checkError(err) defer f.Close() w = io.Writer(f) } else { w = os.Stdout } err := t.Execute(w, env) checkError(err) }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.