fix(git): spinner on all repoactions
Following up on previous commit, added spinner to all repo actions. Also introduced on_all_spinner helper function, which is a version of on_all, but intended for a single repo action (not a composed one like quick), that takes care of managing the spinner. Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
b6e04cf4a4
commit
18e062010e
1 changed files with 18 additions and 5 deletions
23
src/git.rs
23
src/git.rs
|
@ -236,38 +236,51 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn on_all_spinner<F>(&self, op: &str, f: F)
|
||||||
|
where
|
||||||
|
F: Fn(&GitRepo),
|
||||||
|
{
|
||||||
|
for (_, category) in self.categories.iter() {
|
||||||
|
for (_, repo) in category.repos.iter() {
|
||||||
|
let mut sp =
|
||||||
|
Spinner::new(Spinners::Dots10, format!("{}: {}", repo.name, op).into());
|
||||||
|
f(repo);
|
||||||
|
sp.stop_and_persist("✔", format!("{}: {}", repo.name, op).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/// Tries to pull all repositories, skips if fail.
|
/// Tries to pull all repositories, skips if fail.
|
||||||
pub fn pull_all(&self) {
|
pub fn pull_all(&self) {
|
||||||
debug!("exectuting pull_all");
|
debug!("exectuting pull_all");
|
||||||
self.on_all(|repo| {
|
self.on_all_spinner("pull", |repo| {
|
||||||
repo.pull();
|
repo.pull();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/// Tries to clone all repositories, skips if fail.
|
/// Tries to clone all repositories, skips if fail.
|
||||||
pub fn clone_all(&self) {
|
pub fn clone_all(&self) {
|
||||||
debug!("exectuting clone_all");
|
debug!("exectuting clone_all");
|
||||||
self.on_all(|repo| {
|
self.on_all_spinner("clone", |repo| {
|
||||||
repo.clone();
|
repo.clone();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/// Tries to add all work in all repositories, skips if fail.
|
/// Tries to add all work in all repositories, skips if fail.
|
||||||
pub fn add_all(&self) {
|
pub fn add_all(&self) {
|
||||||
debug!("exectuting clone_all");
|
debug!("exectuting clone_all");
|
||||||
self.on_all(|repo| {
|
self.on_all_spinner("add", |repo| {
|
||||||
repo.add_all();
|
repo.add_all();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/// Tries to commit all repositories one at a time, skips if fail.
|
/// Tries to commit all repositories one at a time, skips if fail.
|
||||||
pub fn commit_all(&self) {
|
pub fn commit_all(&self) {
|
||||||
debug!("exectuting clone_all");
|
debug!("exectuting clone_all");
|
||||||
self.on_all(|repo| {
|
self.on_all_spinner("commit", |repo| {
|
||||||
repo.commit();
|
repo.commit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/// Tries to commit all repositories with msg, skips if fail.
|
/// Tries to commit all repositories with msg, skips if fail.
|
||||||
pub fn commit_all_msg(&self, msg: &String) {
|
pub fn commit_all_msg(&self, msg: &String) {
|
||||||
debug!("exectuting clone_all");
|
debug!("exectuting clone_all");
|
||||||
self.on_all(|repo| {
|
self.on_all_spinner("commit", |repo| {
|
||||||
repo.commit_with_msg(msg);
|
repo.commit_with_msg(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue