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

@ -148,11 +148,11 @@ string-with-slash = "\\"
```sh ```sh
$ just --evaluate $ just --evaluate
"tring-with-carriage-return = " "tring-with-carriage-return = "
string-with-double-quote = """ string-with-double-quote = """
string-with-newline = " string-with-newline = "
" "
string-with-slash = "\" string-with-slash = "\"
string-with-tab = " " string-with-tab = " "
``` ```
Single-quoted strings do not support any escape sequences: Single-quoted strings do not support any escape sequences:

View File

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

View File

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