clippy-ify

This commit is contained in:
lyn 2019-03-11 15:09:20 +01:00
parent 9144c816bf
commit abf175111d
3 changed files with 21 additions and 21 deletions

View File

@ -36,7 +36,7 @@ fn main() {
let ts = ThemeSet::load_defaults(); let ts = ThemeSet::load_defaults();
if None == matches.subcommand_name() { if None == matches.subcommand_name() {
println!(""); println!();
println!(r#" welcome to... "#); println!(r#" welcome to... "#);
println!(r#" _ _ _ "#); println!(r#" _ _ _ "#);
println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#); println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#);
@ -44,25 +44,25 @@ fn main() {
println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#); println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#);
println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#); println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#);
println!(r#" |___/ "#); println!(r#" |___/ "#);
println!(""); println!();
} }
if let Some(matches) = matches.subcommand_matches("run") { if let Some(matches) = matches.subcommand_matches("run") {
run(matches.clone()).unwrap(); run(matches.clone()).unwrap();
} }
if let Some(_) = matches.subcommand_matches("verify") { if matches.subcommand_matches("verify").is_some() {
match verify() { match verify() {
Ok(_) => {} Ok(_) => {}
Err(_) => std::process::exit(1), Err(_) => std::process::exit(1),
} }
} }
if let Some(_) = matches.subcommand_matches("watch") { if matches.subcommand_matches("watch").is_some() {
watch().unwrap(); watch().unwrap();
} }
if let None = matches.subcommand_name() { if matches.subcommand_name().is_none() {
let mut highlighter = let mut highlighter =
HighlightFile::new("default_out.md", &ss, &ts.themes["base16-eighties.dark"]).unwrap(); HighlightFile::new("default_out.md", &ss, &ts.themes["base16-eighties.dark"]).unwrap();
for maybe_line in highlighter.reader.lines() { for maybe_line in highlighter.reader.lines() {

View File

@ -30,17 +30,17 @@ pub fn run(matches: clap::ArgMatches) -> Result<(), ()> {
} }
pub fn compile_and_run(filename: &str) -> Result<(), ()> { pub fn compile_and_run(filename: &str) -> Result<(), ()> {
let bar = ProgressBar::new_spinner(); let progress_bar = ProgressBar::new_spinner();
bar.set_message(format!("Compiling {}...", filename).as_str()); progress_bar.set_message(format!("Compiling {}...", filename).as_str());
bar.enable_steady_tick(100); progress_bar.enable_steady_tick(100);
let compilecmd = Command::new("rustc") let compilecmd = Command::new("rustc")
.args(&[filename, "-o", "temp", "--color", "always"]) .args(&[filename, "-o", "temp", "--color", "always"])
.output() .output()
.expect("fail"); .expect("fail");
bar.set_message(format!("Running {}...", filename).as_str()); progress_bar.set_message(format!("Running {}...", filename).as_str());
if compilecmd.status.success() { if compilecmd.status.success() {
let runcmd = Command::new("./temp").output().expect("fail"); let runcmd = Command::new("./temp").output().expect("fail");
bar.finish_and_clear(); progress_bar.finish_and_clear();
if runcmd.status.success() { if runcmd.status.success() {
println!("{}", String::from_utf8_lossy(&runcmd.stdout)); println!("{}", String::from_utf8_lossy(&runcmd.stdout));
@ -58,7 +58,7 @@ pub fn compile_and_run(filename: &str) -> Result<(), ()> {
Err(()) Err(())
} }
} else { } else {
bar.finish_and_clear(); progress_bar.finish_and_clear();
let formatstr = format!( let formatstr = format!(
"{} Compilation of {} failed! Compiler error message:\n", "{} Compilation of {} failed! Compiler error message:\n",
Emoji("⚠️ ", "!"), Emoji("⚠️ ", "!"),

View File

@ -19,14 +19,14 @@ pub fn verify() -> Result<(), ()> {
} }
fn compile_only(filename: &str) -> Result<(), ()> { fn compile_only(filename: &str) -> Result<(), ()> {
let bar = ProgressBar::new_spinner(); let progress_bar = ProgressBar::new_spinner();
bar.set_message(format!("Compiling {}...", filename).as_str()); progress_bar.set_message(format!("Compiling {}...", filename).as_str());
bar.enable_steady_tick(100); progress_bar.enable_steady_tick(100);
let compilecmd = Command::new("rustc") let compilecmd = Command::new("rustc")
.args(&[filename, "-o", "temp", "--color", "always"]) .args(&[filename, "-o", "temp", "--color", "always"])
.output() .output()
.expect("fail"); .expect("fail");
bar.finish_and_clear(); progress_bar.finish_and_clear();
if compilecmd.status.success() { if compilecmd.status.success() {
let formatstr = format!( let formatstr = format!(
"{} Successfully compiled {}!", "{} Successfully compiled {}!",
@ -50,17 +50,17 @@ fn compile_only(filename: &str) -> Result<(), ()> {
} }
pub fn test(filename: &str) -> Result<(), ()> { pub fn test(filename: &str) -> Result<(), ()> {
let bar = ProgressBar::new_spinner(); let progress_bar = ProgressBar::new_spinner();
bar.set_message(format!("Testing {}...", filename).as_str()); progress_bar.set_message(format!("Testing {}...", filename).as_str());
bar.enable_steady_tick(100); progress_bar.enable_steady_tick(100);
let testcmd = Command::new("rustc") let testcmd = Command::new("rustc")
.args(&["--test", filename, "-o", "temp", "--color", "always"]) .args(&["--test", filename, "-o", "temp", "--color", "always"])
.output() .output()
.expect("fail"); .expect("fail");
if testcmd.status.success() { 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"); let runcmd = Command::new("./temp").output().expect("fail");
bar.finish_and_clear(); progress_bar.finish_and_clear();
if runcmd.status.success() { if runcmd.status.success() {
let formatstr = format!("{} Successfully tested {}!", Emoji("", ""), filename); let formatstr = format!("{} Successfully tested {}!", Emoji("", ""), filename);
@ -79,7 +79,7 @@ pub fn test(filename: &str) -> Result<(), ()> {
Err(()) Err(())
} }
} else { } else {
bar.finish_and_clear(); progress_bar.finish_and_clear();
let formatstr = format!( let formatstr = format!(
"{} Compiling of {} failed! Please try again. Here's the output:", "{} Compiling of {} failed! Please try again. Here's the output:",
Emoji("⚠️ ", "!"), Emoji("⚠️ ", "!"),