summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliv <liv@fastmail.com>2019-01-09 22:04:08 +0100
committerliv <liv@fastmail.com>2019-01-09 22:04:08 +0100
commit141db7795b23d066a2b7c798d16c96ff53aa5a52 (patch)
tree95d475ac48bab300b42c8ccef276f08f44ac5e4e
parent17e12433cbe0174fe93196a43953af95ccb71dae (diff)
add --test run flag
-rw-r--r--src/main.rs3
-rw-r--r--src/run.rs8
-rw-r--r--src/verify.rs2
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);