Skip to content

Commit

Permalink
Merge pull request #142 from siketyan/feat/delete-multi-repos
Browse files Browse the repository at this point in the history
feat: Support deleting multiple repos
  • Loading branch information
siketyan authored Apr 25, 2023
2 parents 3a13f48 + d61549f commit c297acd
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/cmd/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::url::Url;
#[derive(Debug, Parser)]
pub struct Cmd {
/// URL or pattern of the repository to delete.
repo: String,
repo: Vec<String>,
}

impl Cmd {
Expand All @@ -34,21 +34,19 @@ impl Cmd {
return Ok(());
}

let url = Url::from_str(
&self.repo,
&config.patterns,
config.defaults.owner.as_deref(),
)?;
let path = PathBuf::from(Path::resolve(&root, &url));

Spinner::new("Deleting the repository...")
.spin_while(|| ready(std::fs::remove_dir_all(&path).map_err(anyhow::Error::from)))
.await?;

info!(
"Deleted the repository successfully: {}",
path.to_string_lossy(),
);
for repo in self.repo.iter() {
let url = Url::from_str(repo, &config.patterns, config.defaults.owner.as_deref())?;
let path = PathBuf::from(Path::resolve(&root, &url));

Spinner::new("Deleting the repository...")
.spin_while(|| ready(std::fs::remove_dir_all(&path).map_err(anyhow::Error::from)))
.await?;

info!(
"Deleted the repository successfully: {}",
path.to_string_lossy(),
);
}

Ok(())
}
Expand Down

0 comments on commit c297acd

Please sign in to comment.