From e7292edf3ccbb76f753e426699e3b3aac32690d0 Mon Sep 17 00:00:00 2001 From: Felix Stein Date: Mon, 16 May 2016 19:01:51 +0200 Subject: [PATCH] Allow setting "--path" even if os.Getwd() fails --- cli.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cli.go b/cli.go index fe82bdcc..997f974e 100644 --- a/cli.go +++ b/cli.go @@ -41,11 +41,18 @@ func main() { acme.UserAgent = "lego/" + app.Version + defaultPath := "" cwd, err := os.Getwd() - if err != nil { - logger().Fatal("Could not determine current working directory. Please pass --path.") + if err == nil { + defaultPath = path.Join(cwd, ".lego") + } + + app.Before = func(c *cli.Context) error { + if c.GlobalString("path") == "" { + logger().Fatal("Could not determine current working directory. Please pass --path.") + } + return nil } - defaultPath := path.Join(cwd, ".lego") app.Commands = []cli.Command{ {