Remove a deleted workspace from `[server.default_workspaces]` if it was the configured default for its org.
(org_slug: &str, deleted_workspace: &str)
| 115 | /// Remove a deleted workspace from `[server.default_workspaces]` if it was |
| 116 | /// the configured default for its org. |
| 117 | fn clean_up_local_config(org_slug: &str, deleted_workspace: &str) -> CliResult<()> { |
| 118 | let mut config = GlobalConfig::load() |
| 119 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to load global config: {e}")))?; |
| 120 | |
| 121 | let was_default = config |
| 122 | .server |
| 123 | .default_workspaces |
| 124 | .get(org_slug) |
| 125 | .map(|v| v == deleted_workspace) |
| 126 | .unwrap_or(false); |
| 127 | |
| 128 | if !was_default { |
| 129 | return Ok(()); |
| 130 | } |
| 131 | |
| 132 | config.server.default_workspaces.remove(org_slug); |
| 133 | config |
| 134 | .save() |
| 135 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to save global config: {e}")))?; |
| 136 | |
| 137 | print_hint(&format!( |
| 138 | "Default workspace for '{org_slug}' was '{deleted_workspace}' — \ |
| 139 | run 'atomic workspace set <slug>' to pick a new one." |
| 140 | )); |
| 141 | |
| 142 | Ok(()) |
| 143 | } |
| 144 | |
| 145 | #[cfg(test)] |
| 146 | mod tests { |
no test coverage detected