Merge pull request #12349 from hashicorp/b-ux
command: color changes, trimming newlines
This commit is contained in:
commit
f735205677
|
@ -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.
|
||||||
`
|
`
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue