diff --git a/command/env_command.go b/command/env_command.go index 425013401..481c0092c 100644 --- a/command/env_command.go +++ b/command/env_command.go @@ -22,7 +22,7 @@ func (c *EnvCommand) Help() string { helpText := ` Usage: terraform env - Create, change and delete Terraform environments. + Create, change and delete Terraform environments. Subcommands: @@ -44,29 +44,41 @@ const ( envExists = `Environment %q already exists` - envDoesNotExist = `Environment %q doesn't exist! + envDoesNotExist = ` +Environment %q doesn't exist! + You can create this environment with the "-new" option.` envChanged = `[reset][green]Switched to environment %q!` - envCreated = `[reset][green]Created environment %q!` + envCreated = ` +[reset][green][bold]Created and switched to environment %q![reset][green] + +You're now on a new, empty environment. Environments isolate their state, +so if you run "terraform plan" Terraform will not see any existing state +for this configuration. +` envDeleted = `[reset][green]Deleted environment %q!` - envNotEmpty = `Environment %[1]q is not empty! -Deleting %[1]q can result in dangling resources: resources that + envNotEmpty = ` +Environment %[1]q is not empty! + +Deleting %[1]q can result in dangling resources: resources that exist but are no longer manageable by Terraform. Please destroy these resources first. If you want to delete this environment anyways and risk dangling resources, use the '-force' flag. ` - envWarnNotEmpty = `[reset][yellow]WARNING: %q was non-empty. + envWarnNotEmpty = `[reset][yellow]WARNING: %q was non-empty. The resources managed by the deleted environment may still exist, but are no longer manageable by Terraform since the state has been deleted. ` - envDelCurrent = `Environment %[1]q is your active environment! + envDelCurrent = ` +Environment %[1]q is your active environment! + You cannot delete the currently active environment. Please switch to another environment and try again. ` diff --git a/command/env_delete.go b/command/env_delete.go index ad484a3f9..a9958f8aa 100644 --- a/command/env_delete.go +++ b/command/env_delete.go @@ -60,12 +60,12 @@ func (c *EnvDeleteCommand) Run(args []string) int { } if !exists { - c.Ui.Error(fmt.Sprintf(envDoesNotExist, delEnv)) + c.Ui.Error(fmt.Sprintf(strings.TrimSpace(envDoesNotExist), delEnv)) return 1 } if delEnv == c.Env() { - c.Ui.Error(fmt.Sprintf(envDelCurrent, delEnv)) + c.Ui.Error(fmt.Sprintf(strings.TrimSpace(envDelCurrent), delEnv)) return 1 } @@ -84,7 +84,7 @@ func (c *EnvDeleteCommand) Run(args []string) int { hasResources := sMgr.State().HasResources() if hasResources && !force { - c.Ui.Error(fmt.Sprintf(envNotEmpty, delEnv)) + c.Ui.Error(fmt.Sprintf(strings.TrimSpace(envNotEmpty), delEnv)) return 1 } diff --git a/command/env_new.go b/command/env_new.go index 47457a0c1..5f4999e24 100644 --- a/command/env_new.go +++ b/command/env_new.go @@ -29,7 +29,7 @@ func (c *EnvNewCommand) Run(args []string) int { } args = cmdFlags.Args() if len(args) == 0 { - c.Ui.Error("expected NAME.\n") + c.Ui.Error("Expected a single argument: NAME.\n") return cli.RunResultHelp } @@ -68,11 +68,8 @@ func (c *EnvNewCommand) Run(args []string) int { return 1 } - c.Ui.Output( - c.Colorize().Color( - fmt.Sprintf(envCreated, newEnv), - ), - ) + c.Ui.Output(c.Colorize().Color(fmt.Sprintf( + strings.TrimSpace(envCreated), newEnv))) if statePath == "" { // if we're not loading a state, then we're done diff --git a/command/env_select.go b/command/env_select.go index d13bdd556..073f92ac5 100644 --- a/command/env_select.go +++ b/command/env_select.go @@ -21,7 +21,7 @@ func (c *EnvSelectCommand) Run(args []string) int { } args = cmdFlags.Args() if len(args) == 0 { - c.Ui.Error("expected NAME.\n") + c.Ui.Error("Expected a single argument: NAME.\n") return cli.RunResultHelp }