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

Method run

atomic-cli/src/commands/workspace/delete.rs:69–112  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

67
68impl 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

Callers

nothing calls this directly

Calls 8

print_warningFunction · 0.85
print_errorFunction · 0.85
build_client_with_orgFunction · 0.85
print_successFunction · 0.85
with_promptMethod · 0.80
delete_workspaceMethod · 0.80
clean_up_local_configFunction · 0.70
defaultMethod · 0.45

Tested by

no test coverage detected