Added spinner for long Git info operations

main
Michal 2 years ago
parent b915ba27b2
commit 6de61cc63e

53
Cargo.lock generated

@ -13,6 +13,7 @@ dependencies = [
"regex",
"serde",
"serde_derive",
"spinoff",
"tabled",
"termion",
"toml",
@ -185,6 +186,12 @@ dependencies = [
"cc",
]
[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "memchr"
version = "2.5.0"
@ -322,6 +329,12 @@ version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "rustversion"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8"
[[package]]
name = "serde"
version = "1.0.140"
@ -339,6 +352,18 @@ dependencies = [
"syn",
]
[[package]]
name = "spinoff"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d3f754b5a185a81fa60acbd32f095411e276743d27307a531d34eae5d49c991"
dependencies = [
"maplit",
"once_cell",
"strum",
"yansi",
]
[[package]]
name = "strip-ansi-escapes"
version = "0.1.1"
@ -354,6 +379,28 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strum"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4faebde00e8ff94316c01800f9054fd2ba77d30d9e922541913051d1d978918b"
dependencies = [
"heck",
"proc-macro2",
"quote",
"rustversion",
"syn",
]
[[package]]
name = "syn"
version = "1.0.98"
@ -501,3 +548,9 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "yansi"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"

@ -30,3 +30,4 @@ colored = { version = "2.0.0", default-features = false }
tabled = { version = "0.8.0", default-features = false, features = ["derive", "color"] }
termion = { version = "1.5.6", default-features = false }
regex = { version = "1.6.0", default-features = false, features = ["std"] }
spinoff = { version = "0.4.0", default-features = false }

@ -2,6 +2,7 @@ use colored::Colorize;
use std::env;
use std::process::Command;
use tabled::Tabled;
use spinoff::{Spinner, Spinners, Color};
use crate::{crash, info, internal::AppExitCode, log};
@ -114,6 +115,8 @@ pub fn info(verbose: bool) {
let repos_unparsed = config.repositories;
let mut repos = vec![];
let mut repos_git = vec![];
let sp = Spinner::new(Spinners::Dots, format!("{}", "Parsing Git Info...".bold()), Color::Green);
for repo in repos_unparsed {
// Get name with branch, '/' serving as the delimiter
let name = if repo.branch.is_some() {
@ -124,11 +127,12 @@ pub fn info(verbose: bool) {
// Get git info, if applicable
let git_info_string = if git_info {
Some(git_status(
let info = Some(git_status(
verbose,
&repo.name,
config.mode.workspace.as_ref().unwrap().colorblind,
))
));
info
} else {
None
};
@ -150,6 +154,15 @@ pub fn info(verbose: bool) {
});
}
}
// Thanks memory management
let symbol = Box::new(format!("{}", "✔".bold().green()));
let done = Box::new(format!("{}", "Done!".bold()));
let symbol: &'static str = Box::leak(symbol);
let done: &'static str = Box::leak(done);
sp.stop_and_persist(symbol, done);
log!(verbose, "Repos: {:?}", repos);
// Sort by priority

Loading…
Cancel
Save