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

Method run

atomic-cli/src/commands/workspace/delete.rs:69–115  ·  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 let (client, org_slug) = build_client_with_org(self.org.as_deref(), None).await?;
75
76 // `--force` skips both the precheck and confirmation.
77 if !self.force {
78 // Check that the workspace exists before prompting.
79 client.get_workspace(&self.slug).await.map_err(remote_err)?;
80
81 print_warning(&format!(
82 "This will permanently delete workspace '{}' and all its projects.",
83 self.slug
84 ));
85
86 let confirmed = dialoguer::Confirm::new()
87 .with_prompt("Are you sure?")
88 .default(false)
89 .interact()
90 .map_err(|e| CliError::Internal(anyhow::anyhow!("Prompt failed: {}", e)))?;
91
92 if !confirmed {
93 print_error("Cancelled.");
94 return Err(CliError::Cancelled);
95 }
96 }
97
98 client
99 .delete_workspace(&self.slug)
100 .await
101 .map_err(remote_err)?;
102
103 print_success(&format!("Deleted workspace: {}", self.slug));
104
105 // If this workspace was the default for the org we just operated
106 // in, remove the stale entry so subsequent commands don't hit a
107 // confusing 404. Server-side deletion succeeded; config cleanup
108 // is best-effort.
109 if let Err(e) = clean_up_local_config(&org_slug, &self.slug) {
110 log::warn!("Failed to clean up local config after workspace delete: {e}");
111 }
112
113 Ok(())
114 })
115 }
116}
117
118/// Remove a deleted workspace from `[server.default_workspaces]` if it was

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected