From e6a3e5e1f3148d55646a6f1f35d22ca0569ce469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20=C3=81ngel=20Jimeno?= Date: Tue, 12 Mar 2019 00:50:04 +0100 Subject: [PATCH] cmd: rename -env to -envfile and use -env to print the environment (#2517) * caddy: Rename env flag to envfile * caddy: Add env flag to print environment variables --- caddy/caddymain/run.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/caddy/caddymain/run.go b/caddy/caddymain/run.go index 61efbd59..dc90d0e1 100644 --- a/caddy/caddymain/run.go +++ b/caddy/caddymain/run.go @@ -53,7 +53,8 @@ func init() { flag.StringVar(&disabledMetrics, "disabled-metrics", "", "Comma-separated list of telemetry metrics to disable") flag.StringVar(&conf, "conf", "", "Caddyfile to load (default \""+caddy.DefaultConfigFile+"\")") flag.StringVar(&cpu, "cpu", "100%", "CPU cap") - flag.StringVar(&envFile, "env", "", "Path to file with environment variables to load in KEY=VALUE format") + flag.BoolVar(&printEnv, "env", false, "Enable to print environment variables") + flag.StringVar(&envFile, "envfile", "", "Path to file with environment variables to load in KEY=VALUE format") flag.BoolVar(&fromJSON, "json-to-caddyfile", false, "From JSON stdin to Caddyfile stdout") flag.BoolVar(&plugins, "plugins", false, "List installed plugins") flag.StringVar(&certmagic.Email, "email", "", "Default ACME CA account email address") @@ -117,6 +118,12 @@ func Run() { mustLogFatalf("%v", err) } + if printEnv { + for _, v := range os.Environ() { + fmt.Println(v) + } + } + // initialize telemetry client if EnableTelemetry { err := initTelemetry() @@ -580,6 +587,7 @@ var ( toJSON bool version bool plugins bool + printEnv bool validate bool disabledMetrics string )