mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
ef9054562e
A lot of commands used `c.Meta.flagSet()` to create the initial flagset for the command, while quite a few of them didn’t actually use or support the flags that are then added. So I updated a few commands to use `flag.NewFlagSet()` instead to only add the flags that are actually needed/supported. Additionally this prevents a few commands from using locking while they actually don’t need locking (as locking is enabled as a default in `c.Meta.flagSet()`.
51 lines
945 B
Go
51 lines
945 B
Go
package command
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/posener/complete"
|
|
)
|
|
|
|
type WorkspaceShowCommand struct {
|
|
Meta
|
|
}
|
|
|
|
func (c *WorkspaceShowCommand) Run(args []string) int {
|
|
args, err := c.Meta.process(args, true)
|
|
if err != nil {
|
|
return 1
|
|
}
|
|
|
|
cmdFlags := c.Meta.extendedFlagSet("workspace show")
|
|
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
|
|
if err := cmdFlags.Parse(args); err != nil {
|
|
return 1
|
|
}
|
|
|
|
workspace := c.Workspace()
|
|
c.Ui.Output(workspace)
|
|
|
|
return 0
|
|
}
|
|
|
|
func (c *WorkspaceShowCommand) AutocompleteArgs() complete.Predictor {
|
|
return complete.PredictNothing
|
|
}
|
|
|
|
func (c *WorkspaceShowCommand) AutocompleteFlags() complete.Flags {
|
|
return nil
|
|
}
|
|
|
|
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"
|
|
}
|