Fix failing env validation

Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
Nathan LeClaire 2015-05-05 13:51:22 -07:00
parent 10afd2da8a
commit 6bb56f91d3
1 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package commands
import (
"errors"
"fmt"
"net/url"
"os"
@ -17,6 +18,10 @@ const (
envTmpl = `{{ .Prefix }}DOCKER_TLS_VERIFY{{ .Delimiter }}{{ .DockerTLSVerify }}{{ .Suffix }}{{ .Prefix }}DOCKER_HOST{{ .Delimiter }}{{ .DockerHost }}{{ .Suffix }}{{ .Prefix }}DOCKER_CERT_PATH{{ .Delimiter }}{{ .DockerCertPath }}{{ .Suffix }}{{ .UsageHint }}`
)
var (
improperEnvArgsError = errors.New("Error: Expected either one machine name, or -u flag to unset the variables in the arguments.")
)
type ShellConfig struct {
Prefix string
Delimiter string
@ -28,8 +33,8 @@ type ShellConfig struct {
}
func cmdEnv(c *cli.Context) {
if len(c.Args()) > 1 {
log.Fatal("Error: Expected either a machine name, or -u flag to unset the variables in the arguments.")
if len(c.Args()) != 1 && !c.Bool("unset") {
log.Fatal(improperEnvArgsError)
}
userShell := c.String("shell")
if userShell == "" {