2017-07-05 16:35:46 -05:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
2019-08-16 07:31:21 -05:00
|
|
|
"fmt"
|
2017-07-05 16:35:46 -05:00
|
|
|
"strings"
|
2017-09-25 21:02:12 -05:00
|
|
|
|
|
|
|
"github.com/posener/complete"
|
2017-07-05 16:35:46 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type WorkspaceShowCommand struct {
|
|
|
|
Meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *WorkspaceShowCommand) Run(args []string) int {
|
2020-04-01 14:01:08 -05:00
|
|
|
args = c.Meta.process(args)
|
2018-11-21 08:35:27 -06:00
|
|
|
cmdFlags := c.Meta.extendedFlagSet("workspace show")
|
2017-07-05 16:35:46 -05:00
|
|
|
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
|
|
|
if err := cmdFlags.Parse(args); err != nil {
|
2019-08-16 07:31:21 -05:00
|
|
|
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
|
2017-07-05 16:35:46 -05:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2020-06-16 11:23:15 -05:00
|
|
|
workspace, err := c.Workspace()
|
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error selecting workspace: %s", err))
|
|
|
|
return 1
|
|
|
|
}
|
2017-07-05 16:35:46 -05:00
|
|
|
c.Ui.Output(workspace)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-09-25 21:02:12 -05:00
|
|
|
func (c *WorkspaceShowCommand) AutocompleteArgs() complete.Predictor {
|
|
|
|
return complete.PredictNothing
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *WorkspaceShowCommand) AutocompleteFlags() complete.Flags {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-07-05 16:35:46 -05:00
|
|
|
func (c *WorkspaceShowCommand) Help() string {
|
|
|
|
helpText := `
|
2021-02-22 08:25:56 -06:00
|
|
|
Usage: terraform [global options] workspace show
|
2017-07-05 16:35:46 -05:00
|
|
|
|
|
|
|
Show the name of the current workspace.
|
|
|
|
`
|
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *WorkspaceShowCommand) Synopsis() string {
|
|
|
|
return "Show the name of the current workspace"
|
|
|
|
}
|