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

Method execute

atomic-cli/src/commands/org/delete.rs:85–135  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

83
84impl OrgDelete {
85 async fn execute(&self) -> CliResult<()> {
86 let client = build_client(self.org.as_deref(), None).await?;
87
88 // `--force` skips both the precheck and confirmation.
89 if !self.force {
90 // Check that the organization exists before prompting.
91 atomic_teams::org::get_org(&client, &self.slug)
92 .await
93 .map_err(|e| CliError::RemoteError {
94 message: e.to_string(),
95 url: None,
96 })?;
97
98 print_warning(&format!(
99 "This will permanently delete organization '{}' and all its data.",
100 self.slug
101 ));
102
103 let confirmed = dialoguer::Confirm::new()
104 .with_prompt("Are you sure?")
105 .default(false)
106 .interact()
107 .map_err(|e| {
108 CliError::Internal(anyhow::anyhow!("Failed to read confirmation: {e}"))
109 })?;
110
111 if !confirmed {
112 return Err(CliError::Cancelled);
113 }
114 }
115
116 atomic_teams::org::delete_org(&client, &self.slug)
117 .await
118 .map_err(|e| CliError::RemoteError {
119 message: e.to_string(),
120 url: None,
121 })?;
122
123 print_success(&format!("Deleted organization: {}", self.slug));
124
125 // Clean up local config: if the deleted org was the current default
126 // or had a configured default workspace, those entries are now stale
127 // and would surface as confusing errors on subsequent commands.
128 // We log but do not fail on config errors here — the server-side
129 // deletion has already succeeded.
130 if let Err(e) = clean_up_local_config(&self.slug) {
131 log::warn!("Failed to clean up local config after org delete: {e}");
132 }
133
134 Ok(())
135 }
136}
137
138/// Remove references to a deleted org from the local global config.

Callers 1

runMethod · 0.45

Calls 8

build_clientFunction · 0.85
get_orgFunction · 0.85
print_warningFunction · 0.85
delete_orgFunction · 0.85
print_successFunction · 0.85
with_promptMethod · 0.80
clean_up_local_configFunction · 0.70
defaultMethod · 0.45

Tested by

no test coverage detected