github.com/paultyng/terraform@v0.6.11-0.20180227224804-66ff8f8bed40/command/workspace_show.go (about)

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