From 27e8cfe4daa2a8105d1430f1e6c034278e43a1f4 Mon Sep 17 00:00:00 2001 From: David Siaw Date: Thu, 14 May 2020 18:03:27 +0900 Subject: [PATCH] fix possible missing name --- cmd/run.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/run.go b/cmd/run.go index 7f79969..63e485e 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -50,12 +50,23 @@ var RunCommand = cli.Command{ detach := c.Bool("detach") envVars := c.StringSlice("envvar") envVarMap, loadEnvVarMapErr := loadEnvVars(envName, heritageName) + if loadEnvVarMapErr != nil { return cli.NewExitError(loadEnvVarMapErr.Error(), 1) } + if len(envName) > 0 && len(heritageName) > 0 { return cli.NewExitError("environment and heritage-name are exclusive", 1) } + + if len(heritageName) == 0 { + env, err := LoadEnvironment(envName) + if err != nil { + return cli.NewExitError(err.Error(), 1) + } + heritageName = env.Name + } + if len(envVars) > 0 { varmap, err := checkEnvVars(envVars) if err != nil { @@ -65,6 +76,7 @@ var RunCommand = cli.Command{ envVarMap[k] = v } } + if len(c.Args()) == 0 { return cli.NewExitError("Command is required", 1) }