MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / clean_up_local_config

Function clean_up_local_config

atomic-cli/src/commands/workspace/delete.rs:117–143  ·  view source on GitHub ↗

Remove a deleted workspace from `[server.default_workspaces]` if it was the configured default for its org.

(org_slug: &str, deleted_workspace: &str)

Source from the content-addressed store, hash-verified

115/// Remove a deleted workspace from `[server.default_workspaces]` if it was
116/// the configured default for its org.
117fn 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)]
146mod tests {

Callers 1

runMethod · 0.70

Calls 4

print_hintFunction · 0.85
getMethod · 0.65
removeMethod · 0.65
saveMethod · 0.45

Tested by

no test coverage detected