Skip to content

Commit

Permalink
Unify removing an evar (case insensitivity)
Browse files Browse the repository at this point in the history
Resolves #537
  • Loading branch information
glinton committed Aug 18, 2017
1 parent 41a844a commit ed70559
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions commands/evar/remove.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package evar

import (
// "fmt"
"fmt"
"strings"

"github.com/spf13/cobra"
Expand All @@ -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"),
Expand All @@ -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 {
Expand All @@ -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))
}
}
}
Expand Down

0 comments on commit ed70559

Please sign in to comment.