From 7cfc37f64765a368632a01260674df72b339a1d6 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sat, 12 Nov 2016 13:12:43 -0800 Subject: [PATCH] Line up names in --evaluate (#93) Fixes #66 --- README.md | 8 ++++---- src/integration.rs | 12 ++++++------ src/lib.rs | 9 +++++++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 94fab36..bb57806 100644 --- a/README.md +++ b/README.md @@ -148,11 +148,11 @@ string-with-slash = "\\" ```sh $ just --evaluate "tring-with-carriage-return = " -string-with-double-quote = """ -string-with-newline = " +string-with-double-quote = """ +string-with-newline = " " -string-with-slash = "\" -string-with-tab = " " +string-with-slash = "\" +string-with-tab = " " ``` Single-quoted strings do not support any escape sequences: diff --git a/src/integration.rs b/src/integration.rs index 9d9f8d0..73ae9b7 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -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" -bar = "b " -baz = "c" -foo = "a " + r#"ab = "a b c" +bar = "b " +foo = "a " +hello = "c" "#, "", ); diff --git a/src/lib.rs b/src/lib.rs index 891eeb9..5cfa312 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(()); }