github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/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 = c.Meta.process(args) 16 cmdFlags := c.Meta.extendedFlagSet("workspace show") 17 cmdFlags.Usage = func() { c.Ui.Error(c.Help()) } 18 if err := cmdFlags.Parse(args); err != nil { 19 c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error())) 20 return 1 21 } 22 23 workspace, err := c.Workspace() 24 if err != nil { 25 c.Ui.Error(fmt.Sprintf("Error selecting workspace: %s", err)) 26 return 1 27 } 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 [global options] 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 }