Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Fix `rad rm` prompt
Alexis Sellier committed 3 years ago
commit 82d858314fd194a56e38692e9e5540602b732274
parent 077c040c08c8cad87fc183b8c2eb2dca7626722a
4 files changed +11 -11
modified radicle-cli/examples/rad-rm.md
@@ -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:
modified radicle-cli/src/commands/rm.rs
@@ -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)
modified radicle-cli/src/terminal/format.rs
@@ -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()
}
modified radicle-cli/src/terminal/io.rs
@@ -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.