1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::commands::kv;
use crate::http;
use crate::kv::namespace::delete;
use crate::settings::global_user::GlobalUser;
use crate::settings::toml::Target;
use crate::terminal::interactive;
use crate::terminal::message::{Message, StdOut};
use anyhow::Result;
pub fn run(target: &Target, user: &GlobalUser, id: &str, force: bool) -> Result<()> {
let client = http::cf_v4_client(user)?;
if !force {
match interactive::confirm(&format!(
"Are you sure you want to delete namespace {}?",
id
)) {
Ok(true) => (),
Ok(false) => {
StdOut::info(&format!("Not deleting namespace {}", id));
return Ok(());
}
Err(e) => anyhow::bail!(e),
}
}
let msg = format!("Deleting namespace {}", id);
StdOut::working(&msg);
let response = delete(client, target.account_id.load()?, id);
match response {
Ok(_) => {
StdOut::success("Success");
StdOut::warn(
"Make sure to remove this \"kv-namespace\" entry from your configuration file!",
)
}
Err(e) => print!("{}", kv::format_error(e)),
}
Ok(())
}