From 59ea57daf66d8201bd9690e227fa397732eab7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Molinero=20Fern=C3=A1ndez?= Date: Sat, 18 Jan 2020 22:59:06 +0100 Subject: [PATCH] cli: Add "LEGO_PATH" environment variable (#1045) Co-authored-by: Ludovic Fernandez --- cmd/flags.go | 7 ++++--- cmd/lego/main.go | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/flags.go b/cmd/flags.go index 46df12ce..93425335 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -50,9 +50,10 @@ func CreateFlags(defaultPath string) []cli.Flag { Usage: "(deprecated) Filename of the generated certificate.", }, cli.StringFlag{ - Name: "path", - Usage: "Directory to use for storing the data.", - Value: defaultPath, + Name: "path", + EnvVar: "LEGO_PATH", + Usage: "Directory to use for storing the data.", + Value: defaultPath, }, cli.BoolFlag{ Name: "http", diff --git a/cmd/lego/main.go b/cmd/lego/main.go index 30ac9149..098d15b9 100644 --- a/cmd/lego/main.go +++ b/cmd/lego/main.go @@ -29,11 +29,12 @@ func main() { fmt.Printf("lego version %s %s/%s\n", c.App.Version, runtime.GOOS, runtime.GOARCH) } - defaultPath := "" + var defaultPath string cwd, err := os.Getwd() if err == nil { defaultPath = filepath.Join(cwd, ".lego") } + app.Flags = cmd.CreateFlags(defaultPath) app.Before = cmd.Before