Merge pull request #11 from ad4mx/main

Changed the way the spinner is stopped
main
Michal 2 years ago committed by GitHub
commit 25fa5f84ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
Cargo.lock generated

@ -485,7 +485,7 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]]
name = "spinoff"
version = "0.4.0"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d3f754b5a185a81fa60acbd32f095411e276743d27307a531d34eae5d49c991"
dependencies = [

@ -29,7 +29,7 @@ colored = { version = "2.0.0", default-features = false }
tabled = { version = "0.8.0", default-features = false, features = ["derive", "color"] }
crossterm = { version = "0.24.0", default-features = false }
regex = { version = "1.6.0", default-features = false, features = ["std"] }
spinoff = { version = "0.4.0", default-features = false }
spinoff = { version = "0.5.2", default-features = false }
rm_rf = { version = "0.6.2", default-features = false }
[target.'cfg(target_os = "linux")'.dependencies]

@ -2,6 +2,7 @@ use colored::Colorize;
use spinoff::{Color, Spinner, Spinners};
use std::env;
use std::fmt::Write;
use std::path::Path;
use std::process::Command;
use tabled::Tabled;
@ -116,6 +117,17 @@ pub fn info(verbose: bool) {
let mut repos_git = vec![];
if git_info {
// Crash early if directories are not found for git_info
for repo in &repos_unparsed {
if !Path::new(&repo.name).exists() {
crash!(
AppExitCode::RepoParseError,
"Failed to check directory {} for Git info, have you initialized the repo?",
repo.name,
);
};
}
// Start the spinner
let sp = Spinner::new(
Spinners::Line,
@ -133,7 +145,7 @@ pub fn info(verbose: bool) {
\n\
# This script will run `git remote update` in all repositories\n\
pull() { cd $1; git remote update; cd -; }\n\
\n"
\n",
);
for repo in &repos_unparsed {
writeln!(bash_script, "pull {} &", repo.name).unwrap();
@ -149,14 +161,8 @@ pub fn info(verbose: bool) {
.output()
.unwrap();
// Because spinoff requires &'static str, we need to Box these in the heap and then leak them to be able to format the spinner
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);
// Stop the spinner with a success message
sp.success(&"Done!".bold());
log!(verbose, "Repos: {:?}", repos);
}

@ -73,7 +73,7 @@ fn do_the_pulling(repos: Vec<String>, verbose: bool, params: &PullParams) {
.unwrap();
}
// Return to root dir
env::set_current_dir(root_dir).unwrap();
env::set_current_dir(&root_dir).unwrap();
log!(
verbose,
"Returned to root dir: {:?}",
@ -87,6 +87,14 @@ fn do_the_pulling(repos: Vec<String>, verbose: bool, params: &PullParams) {
// Push to build
crate::operations::build(&packages_to_rebuild, vec![], params.no_regen, verbose);
// Ensure you are in root dir
env::set_current_dir(root_dir).unwrap();
log!(
verbose,
"Returned to root dir: {:?}",
env::current_dir().unwrap()
);
}
}
}

Loading…
Cancel
Save