radicle_cli/commands/
clean.rs

1mod args;
2
3use radicle::storage;
4use radicle::storage::WriteStorage;
5
6use crate::terminal as term;
7
8pub use args::Args;
9pub(crate) use args::ABOUT;
10
11pub fn run(args: Args, ctx: impl term::Context) -> anyhow::Result<()> {
12    let profile = ctx.profile()?;
13    let storage = &profile.storage;
14    let rid = args.repo;
15    let path = storage::git::paths::repository(storage, &rid);
16
17    if !path.exists() {
18        anyhow::bail!("repository {rid} was not found");
19    }
20
21    if args.no_confirm || term::confirm(format!("Clean {rid}?")) {
22        let cleaned = storage.clean(rid)?;
23        for remote in cleaned {
24            term::info!("Removed {remote}");
25        }
26        term::success!("Successfully cleaned {rid}");
27    }
28
29    Ok(())
30}