Line up names in --evaluate (#93)

Fixes #66
This commit is contained in:
Casey Rodarmor 2016-11-12 13:12:43 -08:00 committed by GitHub
parent edbd94d654
commit 7cfc37f647
3 changed files with 17 additions and 12 deletions

View File

@ -624,18 +624,18 @@ fn evaluate() {
&["--evaluate"],
r#"
foo = "a\t"
baz = "c"
hello = "c"
bar = "b\t"
abc = foo + bar + baz
ab = foo + bar + hello
wut:
touch /this/is/not/a/file
"#,
0,
r#"abc = "a b c"
r#"ab = "a b c"
bar = "b "
baz = "c"
foo = "a "
hello = "c"
"#,
"",
);

View File

@ -19,7 +19,7 @@ extern crate edit_distance;
use std::io::prelude::*;
use std::{fs, fmt, process, io};
use std::{fs, fmt, process, io, cmp};
use std::ops::Range;
use std::fmt::Display;
use regex::Regex;
@ -1093,8 +1093,13 @@ impl<'a, 'b> Justfile<'a> where 'a: 'b {
let scope = evaluate_assignments(&self.assignments, &options.overrides, options.quiet)?;
if options.evaluate {
let mut width = 0;
for name in scope.keys() {
width = cmp::max(name.len(), width);
}
for (name, value) in scope {
println!("{} = \"{}\"", name, value);
println!("{0:1$} = \"{2}\"", name, width, value);
}
return Ok(());
}