Skip to content

Commit

Permalink
explicitly check for length of args
Browse files Browse the repository at this point in the history
  • Loading branch information
Yorick Gersie committed Dec 12, 2017
1 parent 5a5f66d commit 67e17fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,17 @@ func (c *DeployCommand) Run(args []string) int {

args = flags.Args()

if len(args) != 1 {
if len(args) == 1 {
templateFile = args[0]
} else if len(args) == 0 {
templateFile = "levant.nomad"
if _, err := os.Stat(templateFile); os.IsNotExist(err) {
c.UI.Error(c.Help())
return 1
}
} else {
templateFile = args[0]
c.UI.Error(c.Help())
return 1
}

logging.SetLevel(log)
Expand Down
7 changes: 5 additions & 2 deletions command/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ func (c *RenderCommand) Run(args []string) int {

args = flags.Args()

if len(args) != 1 {
if len(args) == 1 {
templateFile = args[0]
} else if len(args) == 0 {
templateFile = "levant.nomad"
if _, err := os.Stat(templateFile); os.IsNotExist(err) {
c.UI.Error(c.Help())
return 1
}
} else {
templateFile = args[0]
c.UI.Error(c.Help())
return 1
}

tpl, err = levant.RenderTemplate(templateFile, variables, &c.Meta.flagVars)
Expand Down

0 comments on commit 67e17fe

Please sign in to comment.