From ed70559d4fd2932a970edeaa41283a6a26497ef5 Mon Sep 17 00:00:00 2001 From: Greg Linton Date: Fri, 18 Aug 2017 10:43:56 -0600 Subject: [PATCH] Unify removing an evar (case insensitivity) Resolves #537 --- commands/evar/remove.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/commands/evar/remove.go b/commands/evar/remove.go index 2b36e0ec..cf0cbd83 100644 --- a/commands/evar/remove.go +++ b/commands/evar/remove.go @@ -1,7 +1,7 @@ package evar import ( - // "fmt" + "fmt" "strings" "github.com/spf13/cobra" @@ -15,9 +15,9 @@ import ( "github.com/nanobox-io/nanobox/util/display" ) -// RemoveCmd ... +// RemoveCmd removes an evar. var RemoveCmd = &cobra.Command{ - Use: "rm", + Use: "rm [local|dry-run] key", Short: "Remove environment variable(s)", Long: ``, // PreRun: steps.Run("login"), @@ -29,6 +29,18 @@ func removeFn(ccmd *cobra.Command, args []string) { // parse the evars excluding the context env, _ := models.FindEnvByID(config.EnvID()) args, location, name := helpers.Endpoint(env, args, 0) + + if len(args) < 1 { + fmt.Printf(` +-------------------------------------------- +Please provide the key you'd like to remove! +-------------------------------------------- + +`) + ccmd.HelpFunc()(ccmd, args) + return + } + evars := parseKeys(args) switch location { @@ -50,7 +62,7 @@ func parseKeys(args []string) []string { for _, arg := range args { for _, key := range strings.Split(arg, ",") { if key != "" { - keys = append(keys, key) + keys = append(keys, strings.ToUpper(key)) } } }