Add '--debug' flag to print justfile with evaluated expressions and
variables
This commit is contained in:
parent
01df3d5e4a
commit
3c80f7f7ae
1
notes
1
notes
@ -3,7 +3,6 @@ notes
|
||||
|
||||
- integration testing
|
||||
. get value of variable --evaluate --variable
|
||||
. --info that prints whole justfile
|
||||
. run app with command line options and test full output (stderr and stdout)
|
||||
. exercise all features and all command line options
|
||||
. underline problem token in error messages
|
||||
|
@ -28,6 +28,9 @@ pub fn app() {
|
||||
.short("l")
|
||||
.long("list")
|
||||
.help("Lists available recipes"))
|
||||
.arg(Arg::with_name("debug")
|
||||
.long("debug")
|
||||
.help("Prints the justfile with debugging information, such as evaluated expression and assignment"))
|
||||
.arg(Arg::with_name("show")
|
||||
.short("s")
|
||||
.long("show")
|
||||
@ -96,6 +99,11 @@ pub fn app() {
|
||||
|
||||
let justfile = super::parse(&text).unwrap_or_else(|error| die!("{}", error));
|
||||
|
||||
if matches.is_present("debug") {
|
||||
println!("{:#}", justfile);
|
||||
process::exit(0);
|
||||
}
|
||||
|
||||
if matches.is_present("list") {
|
||||
if justfile.count() == 0 {
|
||||
warn!("Justfile contains no recipes");
|
||||
|
@ -644,7 +644,7 @@ impl<'a> Display for Justfile<'a> {
|
||||
}
|
||||
items -= 1;
|
||||
if items != 0 {
|
||||
try!(write!(f, "\n"));
|
||||
try!(write!(f, "\n\n"));
|
||||
}
|
||||
}
|
||||
for recipe in self.recipes.values() {
|
||||
@ -655,7 +655,7 @@ impl<'a> Display for Justfile<'a> {
|
||||
}
|
||||
items -= 1;
|
||||
if items != 0 {
|
||||
try!(write!(f, "\n"));
|
||||
try!(write!(f, "\n\n"));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
10
src/tests.rs
10
src/tests.rs
@ -246,8 +246,11 @@ hello a b c : x y z #hello
|
||||
2
|
||||
3
|
||||
", "bar = foo # \"xx\"
|
||||
|
||||
foo = \"xx\" # \"xx\"
|
||||
|
||||
goodbye = \"y\" # \"y\"
|
||||
|
||||
hello a b c: x y z
|
||||
#! blah
|
||||
#blarg
|
||||
@ -255,8 +258,11 @@ hello a b c: x y z
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
x:
|
||||
|
||||
y:
|
||||
|
||||
z:");
|
||||
}
|
||||
|
||||
@ -269,7 +275,9 @@ b = "1"
|
||||
"#,
|
||||
|
||||
r#"a = "0" # "0"
|
||||
|
||||
b = "1" # "1"
|
||||
|
||||
c = a + b + a + b # "0101""#);
|
||||
}
|
||||
|
||||
@ -301,7 +309,7 @@ fn missing_eol() {
|
||||
|
||||
#[test]
|
||||
fn eof_test() {
|
||||
parse_summary("x:\ny:\nz:\na b c: x y z", "a b c: x y z\nx:\ny:\nz:");
|
||||
parse_summary("x:\ny:\nz:\na b c: x y z", "a b c: x y z\n\nx:\n\ny:\n\nz:");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user