From abc78c7652a43e3c998416305fa2038e6c92619f Mon Sep 17 00:00:00 2001 From: Rob Loranger Date: Thu, 8 Aug 2019 10:06:09 -0700 Subject: [PATCH] CurrentUser should always return the flag if set previously when the user flag was provided, the function would still try to get a user from config. flag should take precedence --- config/user.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/user.go b/config/user.go index f62e3d7..45c287d 100644 --- a/config/user.go +++ b/config/user.go @@ -136,6 +136,11 @@ func UserHostDir(c *cli.Context) (string, error) { // CurrentUser returns the username of the user taking action in the current // cli.Context. func CurrentUser(c *cli.Context) (string, error) { + // Use user flag value + if c.GlobalString("user") != "" { + return c.GlobalString("user"), nil + } + // Load host-level config, if host flag is set hostDir, err := UserHostDir(c) if err != nil { @@ -160,10 +165,5 @@ func CurrentUser(c *cli.Context) (string, error) { } } - // Use user flag value - if c.GlobalString("user") != "" { - return c.GlobalString("user"), nil - } - return cfg.Default.User, nil }