terraform/internal/command/arguments/workspace_show.go
Sarah French e24abdf6ff
refactor: Update workspace select and delete subcommands to use the arguments package for parsing arguments and flags (#38429)
* feat: Add `workspace show`-related code to arguments package

* refactor: Update `workspace show` to use the arguments package when parsing arguments

* refactor: Split code for workspace subcommands into separate files in arguments package

* refactor: Move code common to all workspace commands into separate file in arguments package

* feat: Add `workspace delete`-related code to arguments package

* refactor: Update `workspace delete` to use the arguments package when parsing arguments
2026-04-29 08:05:49 -04:00

32 lines
838 B
Go

// Copyright IBM Corp. 2014, 2026
// SPDX-License-Identifier: BUSL-1.1
package arguments
import (
"github.com/hashicorp/terraform/internal/tfdiags"
)
type WorkspaceShow struct {
Workspace
}
func ParseWorkspaceShow(args []string) (*WorkspaceShow, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
cmdFlags := defaultFlagSet("workspace show")
if err := cmdFlags.Parse(args); err != nil {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Failed to parse command-line flags",
err.Error(),
))
}
// `workspace show` takes no positional arguments.
// We could add validation here to return an error when unexpected arguments are present,
// but this would be a breaking change as no validation was performed in this case before.
return &WorkspaceShow{Workspace: Workspace{ViewType: ViewHuman}}, diags
}