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]] [[package]]
name = "spinoff" name = "spinoff"
version = "0.4.0" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d3f754b5a185a81fa60acbd32f095411e276743d27307a531d34eae5d49c991" checksum = "7d3f754b5a185a81fa60acbd32f095411e276743d27307a531d34eae5d49c991"
dependencies = [ dependencies = [

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

@ -2,6 +2,7 @@ use colored::Colorize;
use spinoff::{Color, Spinner, Spinners}; use spinoff::{Color, Spinner, Spinners};
use std::env; use std::env;
use std::fmt::Write; use std::fmt::Write;
use std::path::Path;
use std::process::Command; use std::process::Command;
use tabled::Tabled; use tabled::Tabled;
@ -116,6 +117,17 @@ pub fn info(verbose: bool) {
let mut repos_git = vec![]; let mut repos_git = vec![];
if git_info { 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 // Start the spinner
let sp = Spinner::new( let sp = Spinner::new(
Spinners::Line, Spinners::Line,
@ -133,7 +145,7 @@ pub fn info(verbose: bool) {
\n\ \n\
# This script will run `git remote update` in all repositories\n\ # This script will run `git remote update` in all repositories\n\
pull() { cd $1; git remote update; cd -; }\n\ pull() { cd $1; git remote update; cd -; }\n\
\n" \n",
); );
for repo in &repos_unparsed { for repo in &repos_unparsed {
writeln!(bash_script, "pull {} &", repo.name).unwrap(); writeln!(bash_script, "pull {} &", repo.name).unwrap();
@ -149,14 +161,8 @@ pub fn info(verbose: bool) {
.output() .output()
.unwrap(); .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 // Stop the spinner with a success message
let symbol = Box::new(format!("{}", "✔".bold().green())); sp.success(&"Done!".bold());
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); log!(verbose, "Repos: {:?}", repos);
} }

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