Skip to content

Commit 141db77

Browse files
author
liv
committed
add --test run flag
1 parent 17e1243 commit 141db77

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ fn main() {
2525
.subcommand(
2626
SubCommand::with_name("run")
2727
.alias("r")
28-
.arg(Arg::with_name("file").required(true).index(1)),
28+
.arg(Arg::with_name("file").required(true).index(1))
29+
.arg(Arg::with_name("test").short("t").long("test")),
2930
)
3031
.get_matches();
3132

src/run.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
use crate::util::clean;
2+
use crate::verify::test;
23
use console::{style, Emoji};
34
use indicatif::ProgressBar;
45
use std::process::Command;
56

67
pub fn run(matches: clap::ArgMatches) {
78
if let Some(filename) = matches.value_of("file") {
9+
if matches.is_present("test") {
10+
match test(filename) {
11+
Ok(_) => (),
12+
Err(_) => (),
13+
}
14+
std::process::exit(0);
15+
}
816
let bar = ProgressBar::new_spinner();
917
bar.set_message(format!("Compiling {}...", filename).as_str());
1018
bar.enable_steady_tick(100);

src/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn compile_only(filename: &str) -> Result<(), ()> {
7878
}
7979
}
8080

81-
fn test(filename: &str) -> Result<(), ()> {
81+
pub fn test(filename: &str) -> Result<(), ()> {
8282
let bar = ProgressBar::new_spinner();
8383
bar.set_message(format!("Testing {}...", filename).as_str());
8484
bar.enable_steady_tick(100);

0 commit comments

Comments
 (0)