cli: Fix `rad rm` prompt
This commit is contained in:
parent
077c040c08
commit
82d858314f
|
|
@ -12,7 +12,7 @@ Now let's delete the `heartwood` project:
|
|||
$ rad rm rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --no-confirm
|
||||
! Warning: Failed to untrack repository: failed to connect to node: No such file or directory (os error 2)
|
||||
! Warning: Make sure to untrack this repository when your node is running
|
||||
✓ Successfully removed project rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from storage
|
||||
✓ Successfully removed rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from storage
|
||||
```
|
||||
|
||||
We can check our repositories again to see if it was deleted:
|
||||
|
|
|
|||
|
|
@ -76,18 +76,13 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
if let Ok(Some(_)) = storage.get(signer.public_key(), id.to_owned()) {
|
||||
let path = radicle::storage::git::paths::repository(storage, &id);
|
||||
|
||||
if !options.confirm
|
||||
|| term::confirm(format!(
|
||||
"Are you sure you would like to delete {}?",
|
||||
term::format::dim(id.urn())
|
||||
))
|
||||
{
|
||||
if !options.confirm || term::confirm(format!("Remove {id}?")) {
|
||||
if let Err(e) = rad_untrack::untrack(id.to_owned(), &profile) {
|
||||
term::warning(&format!("Failed to untrack repository: {e}"));
|
||||
term::warning("Make sure to untrack this repository when your node is running");
|
||||
}
|
||||
fs::remove_dir_all(path)?;
|
||||
term::success!("Successfully removed project {id} from storage");
|
||||
term::success!("Successfully removed {id} from storage");
|
||||
}
|
||||
} else {
|
||||
anyhow::bail!("project {} does not exist", &id)
|
||||
|
|
|
|||
|
|
@ -88,6 +88,10 @@ impl<'a> fmt::Display for Identity<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn wrap<D: std::fmt::Display>(msg: D) -> Paint<D> {
|
||||
Paint::wrapping(msg)
|
||||
}
|
||||
|
||||
pub fn negative<D: std::fmt::Display>(msg: D) -> Paint<D> {
|
||||
Paint::red(msg).bold()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,20 +158,21 @@ pub fn fail(header: &str, error: &anyhow::Error) {
|
|||
}
|
||||
|
||||
pub fn ask<D: fmt::Display>(prompt: D, default: bool) -> bool {
|
||||
let prompt = format!("{} {}", Paint::blue("?".to_owned()), prompt);
|
||||
let prompt = prompt.to_string();
|
||||
|
||||
Confirm::new(&prompt)
|
||||
.with_default(default)
|
||||
.with_render_config(*CONFIG)
|
||||
.prompt()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn confirm<D: fmt::Display>(prompt: D) -> bool {
|
||||
ask(format::tertiary(prompt), true)
|
||||
ask(prompt, true)
|
||||
}
|
||||
|
||||
pub fn abort<D: fmt::Display>(prompt: D) -> bool {
|
||||
ask(format::tertiary(prompt), false)
|
||||
ask(prompt, false)
|
||||
}
|
||||
|
||||
/// Get the signer. First we try getting it from ssh-agent, otherwise we prompt the user.
|
||||
|
|
|
|||
Loading…
Reference in New Issue