github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/command/workspace_show.go (about) 1 package command 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/posener/complete" 8 ) 9 10 type WorkspaceShowCommand struct { 11 Meta 12 } 13 14 func (c *WorkspaceShowCommand) Run(args []string) int { 15 args, err := c.Meta.process(args, true) 16 if err != nil { 17 return 1 18 } 19 20 cmdFlags := c.Meta.extendedFlagSet("workspace show") 21 cmdFlags.Usage = func() { c.Ui.Error(c.Help()) } 22 if err := cmdFlags.Parse(args); err != nil { 23 c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error())) 24 return 1 25 } 26 27 workspace := c.Workspace() 28 c.Ui.Output(workspace) 29 30 return 0 31 } 32 33 func (c *WorkspaceShowCommand) AutocompleteArgs() complete.Predictor { 34 return complete.PredictNothing 35 } 36 37 func (c *WorkspaceShowCommand) AutocompleteFlags() complete.Flags { 38 return nil 39 } 40 41 func (c *WorkspaceShowCommand) Help() string { 42 helpText := ` 43 Usage: terraform workspace show 44 45 Show the name of the current workspace. 46 ` 47 return strings.TrimSpace(helpText) 48 } 49 50 func (c *WorkspaceShowCommand) Synopsis() string { 51 return "Show the name of the current workspace" 52 }