From f2b25ae3f15e3e8d737286bd95caa4c85eaa825f Mon Sep 17 00:00:00 2001 From: Tom Barlow Date: Fri, 27 Mar 2015 17:39:26 +0000 Subject: [PATCH] Refactored env usage hint with @ehazlett's review comments Signed-off-by: Tom Barlow --- commands.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/commands.go b/commands.go index 3c19d48f08..bbb67ce3a4 100644 --- a/commands.go +++ b/commands.go @@ -726,7 +726,7 @@ func cmdEnv(c *cli.Context) { } } - usageHint := generateUsageHint(c, userShell) + usageHint := generateUsageHint(c.Args().First(), userShell) switch userShell { case "fish": @@ -738,27 +738,24 @@ func cmdEnv(c *cli.Context) { } } -func generateUsageHint(c *cli.Context, userShell string) string { - msg := "# Run this command to configure your shell: " +func generateUsageHint(machineName string, userShell string) string { cmd := "" - machine := c.Args().First() - switch userShell { case "fish": - if machine != "" { - cmd = fmt.Sprintf("eval (docker-machine env %s)", machine) + if machineName != "" { + cmd = fmt.Sprintf("eval (docker-machine env %s)", machineName) } else { cmd = "eval (docker-machine env)" } default: - if machine != "" { - cmd = fmt.Sprintf("eval $(docker-machine env %s)", machine) + if machineName != "" { + cmd = fmt.Sprintf("eval $(docker-machine env %s)", machineName) } else { cmd = "eval $(docker-machine env)" } } - return fmt.Sprintf("%s %s\n", msg, cmd) + return fmt.Sprintf("# Run this command to configure your shell: %s\n", cmd) } func cmdSsh(c *cli.Context) {