command: color changes, trimming newlines

This commit is contained in:
Mitchell Hashimoto 2017-03-01 12:59:40 -08:00
parent 4f680aa5b8
commit 1f614bd4d6
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
4 changed files with 26 additions and 17 deletions

View File

@ -44,16 +44,26 @@ const (
envExists = `Environment %q already exists` 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.` You can create this environment with the "-new" option.`
envChanged = `[reset][green]Switched to environment %q!` 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!` envDeleted = `[reset][green]Deleted environment %q!`
envNotEmpty = `Environment %[1]q is not empty! envNotEmpty = `
Environment %[1]q is not empty!
Deleting %[1]q can result in dangling resources: resources that Deleting %[1]q can result in dangling resources: resources that
exist but are no longer manageable by Terraform. Please destroy exist but are no longer manageable by Terraform. Please destroy
these resources first. If you want to delete this environment these resources first. If you want to delete this environment
@ -66,7 +76,9 @@ but are no longer manageable by Terraform since the state has
been deleted. 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 You cannot delete the currently active environment. Please switch
to another environment and try again. to another environment and try again.
` `

View File

@ -60,12 +60,12 @@ func (c *EnvDeleteCommand) Run(args []string) int {
} }
if !exists { if !exists {
c.Ui.Error(fmt.Sprintf(envDoesNotExist, delEnv)) c.Ui.Error(fmt.Sprintf(strings.TrimSpace(envDoesNotExist), delEnv))
return 1 return 1
} }
if delEnv == c.Env() { if delEnv == c.Env() {
c.Ui.Error(fmt.Sprintf(envDelCurrent, delEnv)) c.Ui.Error(fmt.Sprintf(strings.TrimSpace(envDelCurrent), delEnv))
return 1 return 1
} }
@ -84,7 +84,7 @@ func (c *EnvDeleteCommand) Run(args []string) int {
hasResources := sMgr.State().HasResources() hasResources := sMgr.State().HasResources()
if hasResources && !force { if hasResources && !force {
c.Ui.Error(fmt.Sprintf(envNotEmpty, delEnv)) c.Ui.Error(fmt.Sprintf(strings.TrimSpace(envNotEmpty), delEnv))
return 1 return 1
} }

View File

@ -29,7 +29,7 @@ func (c *EnvNewCommand) Run(args []string) int {
} }
args = cmdFlags.Args() args = cmdFlags.Args()
if len(args) == 0 { if len(args) == 0 {
c.Ui.Error("expected NAME.\n") c.Ui.Error("Expected a single argument: NAME.\n")
return cli.RunResultHelp return cli.RunResultHelp
} }
@ -68,11 +68,8 @@ func (c *EnvNewCommand) Run(args []string) int {
return 1 return 1
} }
c.Ui.Output( c.Ui.Output(c.Colorize().Color(fmt.Sprintf(
c.Colorize().Color( strings.TrimSpace(envCreated), newEnv)))
fmt.Sprintf(envCreated, newEnv),
),
)
if statePath == "" { if statePath == "" {
// if we're not loading a state, then we're done // if we're not loading a state, then we're done

View File

@ -21,7 +21,7 @@ func (c *EnvSelectCommand) Run(args []string) int {
} }
args = cmdFlags.Args() args = cmdFlags.Args()
if len(args) == 0 { if len(args) == 0 {
c.Ui.Error("expected NAME.\n") c.Ui.Error("Expected a single argument: NAME.\n")
return cli.RunResultHelp return cli.RunResultHelp
} }