mirror of https://github.com/hashicorp/terraform
This command serves as an alternative to the human-oriented list of workspaces for scripting use-cases where it's useful to know the _current_ workspace name.pull/15479/head
parent
909989acfa
commit
9d7fce2f69
@ -0,0 +1,37 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type WorkspaceShowCommand struct {
|
||||
Meta
|
||||
}
|
||||
|
||||
func (c *WorkspaceShowCommand) Run(args []string) int {
|
||||
args = c.Meta.process(args, true)
|
||||
|
||||
cmdFlags := c.Meta.flagSet("workspace show")
|
||||
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
if err := cmdFlags.Parse(args); err != nil {
|
||||
return 1
|
||||
}
|
||||
|
||||
workspace := c.Workspace()
|
||||
c.Ui.Output(workspace)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (c *WorkspaceShowCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: terraform workspace show
|
||||
|
||||
Show the name of the current workspace.
|
||||
`
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *WorkspaceShowCommand) Synopsis() string {
|
||||
return "Show the name of the current workspace"
|
||||
}
|
||||
Loading…
Reference in new issue