(deps commandDeps)
| 319 | } |
| 320 | |
| 321 | func newWorkspaceRemoveCommand(deps commandDeps) *cobra.Command { |
| 322 | return &cobra.Command{ |
| 323 | Use: "remove <name-or-id>", |
| 324 | Short: "Remove a workspace registration and stopped session history", |
| 325 | Example: ` # Remove a workspace registration by name |
| 326 | agh workspace remove checkout-api`, |
| 327 | Args: exactOneNonBlankArg(), |
| 328 | RunE: func(cmd *cobra.Command, args []string) error { |
| 329 | client, err := clientFromDeps(deps) |
| 330 | if err != nil { |
| 331 | return err |
| 332 | } |
| 333 | |
| 334 | detail, err := client.GetWorkspace(cmd.Context(), args[0]) |
| 335 | if err != nil { |
| 336 | return err |
| 337 | } |
| 338 | if err := client.DeleteWorkspace(cmd.Context(), detail.Workspace.ID); err != nil { |
| 339 | return err |
| 340 | } |
| 341 | |
| 342 | return writeCommandOutput(cmd, workspaceRecordBundle(detail.Workspace)) |
| 343 | }, |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | func workspaceRecordBundle(item WorkspaceRecord) outputBundle { |
| 348 | return outputBundle{ |
no test coverage detected