(&self)
| 67 | |
| 68 | impl Command for WorkspaceDelete { |
| 69 | fn run(&self) -> CliResult<()> { |
| 70 | let rt = tokio::runtime::Runtime::new() |
| 71 | .map_err(|e| CliError::Internal(anyhow::anyhow!("{}", e)))?; |
| 72 | |
| 73 | rt.block_on(async { |
| 74 | // Confirm unless --force is set. |
| 75 | if !self.force { |
| 76 | print_warning(&format!( |
| 77 | "This will permanently delete workspace '{}' and all its projects.", |
| 78 | self.slug |
| 79 | )); |
| 80 | |
| 81 | let confirmed = dialoguer::Confirm::new() |
| 82 | .with_prompt("Are you sure?") |
| 83 | .default(false) |
| 84 | .interact() |
| 85 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Prompt failed: {}", e)))?; |
| 86 | |
| 87 | if !confirmed { |
| 88 | print_error("Cancelled."); |
| 89 | return Err(CliError::Cancelled); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | let (client, org_slug) = build_client_with_org(self.org.as_deref(), None).await?; |
| 94 | |
| 95 | client |
| 96 | .delete_workspace(&self.slug) |
| 97 | .await |
| 98 | .map_err(remote_err)?; |
| 99 | |
| 100 | print_success(&format!("Deleted workspace: {}", self.slug)); |
| 101 | |
| 102 | // If this workspace was the default for the org we just operated |
| 103 | // in, remove the stale entry so subsequent commands don't hit a |
| 104 | // confusing 404. Server-side deletion succeeded; config cleanup |
| 105 | // is best-effort. |
| 106 | if let Err(e) = clean_up_local_config(&org_slug, &self.slug) { |
| 107 | log::warn!("Failed to clean up local config after workspace delete: {e}"); |
| 108 | } |
| 109 | |
| 110 | Ok(()) |
| 111 | }) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /// Remove a deleted workspace from `[server.default_workspaces]` if it was |
nothing calls this directly
no test coverage detected