Skip to content

Commit

Permalink
command: Run validation before asking for input. Fixes #602
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Dec 9, 2014
1 parent 57fd308 commit 5b745e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions command/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ func (c *ApplyCommand) Run(args []string) int {
return 1
}
}
if !validateContext(ctx, c.Ui) {
return 1
}
if !planned {
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
return 1
}
}
if !validateContext(ctx, c.Ui) {
return 1
}

// Create a backup of the state before updating
if backupPath != "-" && c.state != nil {
Expand Down
6 changes: 3 additions & 3 deletions command/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ func (c *PlanCommand) Run(args []string) int {
c.Ui.Error(err.Error())
return 1
}
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
if !validateContext(ctx, c.Ui) {
return 1
}
if !validateContext(ctx, c.Ui) {
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
return 1
}

Expand Down
6 changes: 3 additions & 3 deletions command/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ func (c *RefreshCommand) Run(args []string) int {
c.Ui.Error(err.Error())
return 1
}
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
if !validateContext(ctx, c.Ui) {
return 1
}
if !validateContext(ctx, c.Ui) {
if err := ctx.Input(c.InputMode()); err != nil {
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
return 1
}

Expand Down

0 comments on commit 5b745e5

Please sign in to comment.