(
&self,
client: &StorageClient,
ws_slug: &str,
proj_slug: &str,
confirm: F,
)
| 87 | |
| 88 | impl ProjectDelete { |
| 89 | async fn execute_with_client<F>( |
| 90 | &self, |
| 91 | client: &StorageClient, |
| 92 | ws_slug: &str, |
| 93 | proj_slug: &str, |
| 94 | confirm: F, |
| 95 | ) -> CliResult<()> |
| 96 | where |
| 97 | F: FnOnce(&str) -> CliResult<bool>, |
| 98 | { |
| 99 | // Interactive deletes validate the target before asking the user to |
| 100 | // confirm. Forced deletes keep the single-request path for scripts. |
| 101 | if !self.force { |
| 102 | client |
| 103 | .get_project(ws_slug, proj_slug) |
| 104 | .await |
| 105 | .map_err(|e| map_project_error(e, ws_slug, proj_slug))?; |
| 106 | |
| 107 | let prompt = format!( |
| 108 | "Delete project '{}' from workspace '{}'? This cannot be undone.", |
| 109 | proj_slug, ws_slug, |
| 110 | ); |
| 111 | |
| 112 | if !confirm(&prompt)? { |
| 113 | return Err(CliError::Cancelled); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | client |
| 118 | .delete_project(ws_slug, proj_slug) |
| 119 | .await |
| 120 | .map_err(|e| map_project_error(e, ws_slug, proj_slug))?; |
| 121 | |
| 122 | print_success(&format!( |
| 123 | "Deleted project {} from workspace {}", |
| 124 | proj_slug, ws_slug, |
| 125 | )); |
| 126 | |
| 127 | Ok(()) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | fn map_project_error( |
no test coverage detected