mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
6f82ad09c8
This makes the english consistent on flags, and improves the contrast for the placeholder color on dark themes.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/coder/coder/cli/cliui"
|
|
)
|
|
|
|
func show() *cobra.Command {
|
|
return &cobra.Command{
|
|
Annotations: workspaceCommand,
|
|
Use: "show <workspace>",
|
|
Short: "Display details of a workspace's resources and agents",
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
client, err := CreateClient(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
buildInfo, err := client.BuildInfo(cmd.Context())
|
|
if err != nil {
|
|
return xerrors.Errorf("get server version: %w", err)
|
|
}
|
|
workspace, err := namedWorkspace(cmd, client, args[0])
|
|
if err != nil {
|
|
return xerrors.Errorf("get workspace: %w", err)
|
|
}
|
|
resources, err := client.WorkspaceResourcesByBuild(cmd.Context(), workspace.LatestBuild.ID)
|
|
if err != nil {
|
|
return xerrors.Errorf("get workspace resources: %w", err)
|
|
}
|
|
return cliui.WorkspaceResources(cmd.OutOrStdout(), resources, cliui.WorkspaceResourcesOptions{
|
|
WorkspaceName: workspace.Name,
|
|
ServerVersion: buildInfo.Version,
|
|
})
|
|
},
|
|
}
|
|
}
|