2017-07-05 23:35:46 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
2019-08-16 14:31:21 +02:00
|
|
|
"fmt"
|
2017-07-05 23:35:46 +02:00
|
|
|
"strings"
|
2017-09-26 04:02:12 +02:00
|
|
|
|
|
|
|
"github.com/posener/complete"
|
2017-07-05 23:35:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type WorkspaceShowCommand struct {
|
|
|
|
Meta
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *WorkspaceShowCommand) Run(args []string) int {
|
2020-04-01 21:01:08 +02:00
|
|
|
args = c.Meta.process(args)
|
2018-11-21 15:35:27 +01:00
|
|
|
cmdFlags := c.Meta.extendedFlagSet("workspace show")
|
2017-07-05 23:35:46 +02:00
|
|
|
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
|
|
|
if err := cmdFlags.Parse(args); err != nil {
|
2019-08-16 14:31:21 +02:00
|
|
|
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
|
2017-07-05 23:35:46 +02:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2020-06-16 18:23:15 +02:00
|
|
|
workspace, err := c.Workspace()
|
|
|
|
if err != nil {
|
|
|
|
c.Ui.Error(fmt.Sprintf("Error selecting workspace: %s", err))
|
|
|
|
return 1
|
|
|
|
}
|
2017-07-05 23:35:46 +02:00
|
|
|
c.Ui.Output(workspace)
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2017-09-26 04:02:12 +02:00
|
|
|
func (c *WorkspaceShowCommand) AutocompleteArgs() complete.Predictor {
|
|
|
|
return complete.PredictNothing
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *WorkspaceShowCommand) AutocompleteFlags() complete.Flags {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-07-05 23:35:46 +02:00
|
|
|
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"
|
|
|
|
}
|