From 38f8de15bfdb876c1e7a162c0002fbd4584209a2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 4 Jan 2018 12:10:07 +0100 Subject: [PATCH] Revert "Integrate spinner for nicer progress reports" This reverts commit de7a4d2dfb16e1bd32a52e146719f2658dd6fdad. --- bin/core/imag-init/Cargo.toml | 1 - bin/core/imag-init/src/main.rs | 42 ++++++++++++---------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/bin/core/imag-init/Cargo.toml b/bin/core/imag-init/Cargo.toml index 14600eb4..547e36b2 100644 --- a/bin/core/imag-init/Cargo.toml +++ b/bin/core/imag-init/Cargo.toml @@ -22,7 +22,6 @@ maintenance = { status = "actively-developed" } [dependencies] clap = ">=2.17" version = "2.0.1" -spinner = "0.3" [dev-dependencies] toml = "0.4" diff --git a/bin/core/imag-init/src/main.rs b/bin/core/imag-init/src/main.rs index d973fb1c..03908d91 100644 --- a/bin/core/imag-init/src/main.rs +++ b/bin/core/imag-init/src/main.rs @@ -33,7 +33,6 @@ )] extern crate clap; -extern crate spinner; #[macro_use] extern crate version; #[cfg(test)] @@ -47,8 +46,6 @@ use std::path::PathBuf; use std::path::Path; use std::process::Command; -use spinner::SpinnerBuilder; - const CONFIGURATION_STR : &'static str = include_str!("../../../../imagrc.toml"); const GITIGNORE_STR : &'static str = r#" # We ignore the imagrc.toml file by default @@ -64,21 +61,14 @@ imagrc.toml "#; fn main() { - let sp = SpinnerBuilder::new("imag-init".into()).start(); - - sp.update("Building ui".into()); let app = ui::build_ui(); - - sp.update("Getting matches".into()); let matches = app.get_matches(); - sp.update("Evaluating commandline".into()); let path = matches .value_of("path") .map(String::from) .map(PathBuf::from) .unwrap_or_else(|| { - sp.update("Fetching $HOME and building imag path".into()); ::std::env::var("HOME") .map(PathBuf::from) .map(|mut p| { p.push(".imag"); p }) @@ -92,7 +82,6 @@ fn main() { .expect("Failed to retrieve/build path for imag directory.") }); - sp.update("Creating imag directories".into()); let _ = ::std::fs::create_dir_all(path.clone()) .expect("Failed to create directory"); @@ -102,7 +91,6 @@ fn main() { config_path }; - sp.update("Writing configuration file".into()); let _ = OpenOptions::new() .write(true) .create(true) @@ -119,7 +107,6 @@ fn main() { }) .expect("Failed to open new configuration file"); - sp.update("Checking for git".into()); if find_command("git").is_some() && !matches.is_present("nogit") { // we initialize a git repository println!("Going to initialize a git repository in the imag directory..."); @@ -130,7 +117,6 @@ fn main() { gitignore_path.to_str().map(String::from).expect("Cannot convert path to string") }; - sp.update("Writing gitignore".into()); let _ = OpenOptions::new() .write(true) .create(true) @@ -145,43 +131,46 @@ fn main() { let worktree = format!("--work-tree={}", path_str); let gitdir = format!("--git-dir={}", path_str); - sp.update("Initializing git repository".into()); { let output = Command::new("git") .args(&[&worktree, &gitdir, "--no-pager", "init"]) .output() .expect("Calling 'git init' failed"); - if !output.status.success() { - sp.close(); + if output.status.success() { + println!("{}", String::from_utf8(output.stdout).expect("No UTF-8 output")); + println!("'git {} {} --no-pager init' succeeded", worktree, gitdir); + } else { println!("{}", String::from_utf8(output.stderr).expect("No UTF-8 output")); - ::std::process::exit(output.status.code().unwrap_or(1)) + ::std::process::exit(output.status.code().unwrap_or(1)); } } - sp.update("Adding gitignore to repository".into()); { let output = Command::new("git") .args(&[&worktree, &gitdir, "--no-pager", "add", &gitignore_path]) .output() .expect("Calling 'git add' failed"); - if !output.status.success() { - sp.close(); + if output.status.success() { + println!("{}", String::from_utf8(output.stdout).expect("No UTF-8 output")); + println!("'git {} {} --no-pager add {}' succeeded", worktree, gitdir, gitignore_path); + } else { println!("{}", String::from_utf8(output.stderr).expect("No UTF-8 output")); - ::std::process::exit(output.status.code().unwrap_or(1)) + ::std::process::exit(output.status.code().unwrap_or(1)); } } - sp.update("Committing gitignore to repository".into()); { let output = Command::new("git") .args(&[&worktree, &gitdir, "--no-pager", "commit", &gitignore_path, "-m", "'Initial import'"]) .output() .expect("Calling 'git commit' failed"); - if !output.status.success() { - sp.close(); + if output.status.success() { + println!("{}", String::from_utf8(output.stdout).expect("No UTF-8 output")); + println!("'git {} {} --no-pager commit {} -m 'Initial import'' succeeded", worktree, gitdir, gitignore_path); + } else { println!("{}", String::from_utf8(output.stderr).expect("No UTF-8 output")); - ::std::process::exit(output.status.code().unwrap_or(1)) + ::std::process::exit(output.status.code().unwrap_or(1)); } } @@ -190,7 +179,6 @@ fn main() { println!("No git repository will be initialized"); } - sp.message("Done".into()); println!("Ready. Have fun with imag!"); }