Skip to content

Commit

Permalink
clippy-ify
Browse files Browse the repository at this point in the history
  • Loading branch information
komaeda committed Mar 11, 2019
1 parent 9144c81 commit abf1751
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,33 @@ fn main() {
let ts = ThemeSet::load_defaults();

if None == matches.subcommand_name() {
println!("");
println!();
println!(r#" welcome to... "#);
println!(r#" _ _ _ "#);
println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#);
println!(r#" | '__| | | / __| __| | | '_ \ / _` / __| "#);
println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#);
println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#);
println!(r#" |___/ "#);
println!("");
println!();
}

if let Some(matches) = matches.subcommand_matches("run") {
run(matches.clone()).unwrap();
}

if let Some(_) = matches.subcommand_matches("verify") {
if matches.subcommand_matches("verify").is_some() {
match verify() {
Ok(_) => {}
Err(_) => std::process::exit(1),
}
}

if let Some(_) = matches.subcommand_matches("watch") {
if matches.subcommand_matches("watch").is_some() {
watch().unwrap();
}

if let None = matches.subcommand_name() {
if matches.subcommand_name().is_none() {
let mut highlighter =
HighlightFile::new("default_out.md", &ss, &ts.themes["base16-eighties.dark"]).unwrap();
for maybe_line in highlighter.reader.lines() {
Expand Down
12 changes: 6 additions & 6 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ pub fn run(matches: clap::ArgMatches) -> Result<(), ()> {
}

pub fn compile_and_run(filename: &str) -> Result<(), ()> {
let bar = ProgressBar::new_spinner();
bar.set_message(format!("Compiling {}...", filename).as_str());
bar.enable_steady_tick(100);
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Compiling {}...", filename).as_str());
progress_bar.enable_steady_tick(100);
let compilecmd = Command::new("rustc")
.args(&[filename, "-o", "temp", "--color", "always"])
.output()
.expect("fail");
bar.set_message(format!("Running {}...", filename).as_str());
progress_bar.set_message(format!("Running {}...", filename).as_str());
if compilecmd.status.success() {
let runcmd = Command::new("./temp").output().expect("fail");
bar.finish_and_clear();
progress_bar.finish_and_clear();

if runcmd.status.success() {
println!("{}", String::from_utf8_lossy(&runcmd.stdout));
Expand All @@ -58,7 +58,7 @@ pub fn compile_and_run(filename: &str) -> Result<(), ()> {
Err(())
}
} else {
bar.finish_and_clear();
progress_bar.finish_and_clear();
let formatstr = format!(
"{} Compilation of {} failed! Compiler error message:\n",
Emoji("⚠️ ", "!"),
Expand Down
20 changes: 10 additions & 10 deletions src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ pub fn verify() -> Result<(), ()> {
}

fn compile_only(filename: &str) -> Result<(), ()> {
let bar = ProgressBar::new_spinner();
bar.set_message(format!("Compiling {}...", filename).as_str());
bar.enable_steady_tick(100);
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Compiling {}...", filename).as_str());
progress_bar.enable_steady_tick(100);
let compilecmd = Command::new("rustc")
.args(&[filename, "-o", "temp", "--color", "always"])
.output()
.expect("fail");
bar.finish_and_clear();
progress_bar.finish_and_clear();
if compilecmd.status.success() {
let formatstr = format!(
"{} Successfully compiled {}!",
Expand All @@ -50,17 +50,17 @@ fn compile_only(filename: &str) -> Result<(), ()> {
}

pub fn test(filename: &str) -> Result<(), ()> {
let bar = ProgressBar::new_spinner();
bar.set_message(format!("Testing {}...", filename).as_str());
bar.enable_steady_tick(100);
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Testing {}...", filename).as_str());
progress_bar.enable_steady_tick(100);
let testcmd = Command::new("rustc")
.args(&["--test", filename, "-o", "temp", "--color", "always"])
.output()
.expect("fail");
if testcmd.status.success() {
bar.set_message(format!("Running {}...", filename).as_str());
progress_bar.set_message(format!("Running {}...", filename).as_str());
let runcmd = Command::new("./temp").output().expect("fail");
bar.finish_and_clear();
progress_bar.finish_and_clear();

if runcmd.status.success() {
let formatstr = format!("{} Successfully tested {}!", Emoji("✅", "✓"), filename);
Expand All @@ -79,7 +79,7 @@ pub fn test(filename: &str) -> Result<(), ()> {
Err(())
}
} else {
bar.finish_and_clear();
progress_bar.finish_and_clear();
let formatstr = format!(
"{} Compiling of {} failed! Please try again. Here's the output:",
Emoji("⚠️ ", "!"),
Expand Down

0 comments on commit abf1751

Please sign in to comment.