| 23 | } |
| 24 | |
| 25 | func newViewCmd(app *App) *cobra.Command { |
| 26 | opts := &viewOptions{} |
| 27 | |
| 28 | viewCmd := &cobra.Command{ |
| 29 | Use: "view", |
| 30 | Short: "View details about a codespace", |
| 31 | Example: heredoc.Doc(` |
| 32 | # Select a codespace from a list of all codespaces you own |
| 33 | $ gh cs view |
| 34 | |
| 35 | # View the details of a specific codespace |
| 36 | $ gh cs view -c codespace-name-12345 |
| 37 | |
| 38 | # View the list of all available fields for a codespace |
| 39 | $ gh cs view --json |
| 40 | |
| 41 | # View specific fields for a codespace |
| 42 | $ gh cs view --json displayName,machineDisplayName,state |
| 43 | `), |
| 44 | Args: noArgsConstraint, |
| 45 | RunE: func(cmd *cobra.Command, args []string) error { |
| 46 | return app.ViewCodespace(cmd.Context(), opts) |
| 47 | }, |
| 48 | } |
| 49 | opts.selector = AddCodespaceSelector(viewCmd, app.apiClient) |
| 50 | cmdutil.AddJSONFlags(viewCmd, &opts.exporter, api.ViewCodespaceFields) |
| 51 | |
| 52 | return viewCmd |
| 53 | } |
| 54 | |
| 55 | func (a *App) ViewCodespace(ctx context.Context, opts *viewOptions) error { |
| 56 | // If we are in a codespace and a codespace name wasn't provided, show the details for the codespace we are connected to |