From 141db7795b23d066a2b7c798d16c96ff53aa5a52 Mon Sep 17 00:00:00 2001 From: liv Date: Wed, 9 Jan 2019 22:04:08 +0100 Subject: [PATCH] add --test run flag --- src/main.rs | 3 ++- src/run.rs | 8 ++++++++ src/verify.rs | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 779e4b9..b74cda7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,8 @@ fn main() { .subcommand( SubCommand::with_name("run") .alias("r") - .arg(Arg::with_name("file").required(true).index(1)), + .arg(Arg::with_name("file").required(true).index(1)) + .arg(Arg::with_name("test").short("t").long("test")), ) .get_matches(); diff --git a/src/run.rs b/src/run.rs index 093d1e4..809b79d 100644 --- a/src/run.rs +++ b/src/run.rs @@ -1,10 +1,18 @@ use crate::util::clean; +use crate::verify::test; use console::{style, Emoji}; use indicatif::ProgressBar; use std::process::Command; pub fn run(matches: clap::ArgMatches) { if let Some(filename) = matches.value_of("file") { + if matches.is_present("test") { + match test(filename) { + Ok(_) => (), + Err(_) => (), + } + std::process::exit(0); + } let bar = ProgressBar::new_spinner(); bar.set_message(format!("Compiling {}...", filename).as_str()); bar.enable_steady_tick(100); diff --git a/src/verify.rs b/src/verify.rs index 5e5108c..c5f3266 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -78,7 +78,7 @@ fn compile_only(filename: &str) -> Result<(), ()> { } } -fn test(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);