-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
command: "terraform workspace show" to print current workspace name
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.
- Loading branch information
1 parent
909989a
commit 9d7fce2
Showing
4 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters