(&self)
| 83 | |
| 84 | impl OrgDelete { |
| 85 | async fn execute(&self) -> CliResult<()> { |
| 86 | // Prompt for confirmation unless --force is set. |
| 87 | if !self.force { |
| 88 | print_warning(&format!( |
| 89 | "This will permanently delete organization '{}' and all its data.", |
| 90 | self.slug |
| 91 | )); |
| 92 | |
| 93 | let confirmed = dialoguer::Confirm::new() |
| 94 | .with_prompt("Are you sure?") |
| 95 | .default(false) |
| 96 | .interact() |
| 97 | .map_err(|e| { |
| 98 | CliError::Internal(anyhow::anyhow!("Failed to read confirmation: {e}")) |
| 99 | })?; |
| 100 | |
| 101 | if !confirmed { |
| 102 | return Err(CliError::Cancelled); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | let client = build_client(self.org.as_deref(), None).await?; |
| 107 | |
| 108 | atomic_teams::org::delete_org(&client, &self.slug) |
| 109 | .await |
| 110 | .map_err(|e| CliError::RemoteError { |
| 111 | message: e.to_string(), |
| 112 | url: None, |
| 113 | })?; |
| 114 | |
| 115 | print_success(&format!("Deleted organization: {}", self.slug)); |
| 116 | |
| 117 | // Clean up local config: if the deleted org was the current default |
| 118 | // or had a configured default workspace, those entries are now stale |
| 119 | // and would surface as confusing errors on subsequent commands. |
| 120 | // We log but do not fail on config errors here — the server-side |
| 121 | // deletion has already succeeded. |
| 122 | if let Err(e) = clean_up_local_config(&self.slug) { |
| 123 | log::warn!("Failed to clean up local config after org delete: {e}"); |
| 124 | } |
| 125 | |
| 126 | Ok(()) |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /// Remove references to a deleted org from the local global config. |
no test coverage detected