diff --git a/src/app.rs b/src/app.rs index aaab7bd..b897b6f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -115,6 +115,9 @@ pub fn app() { .arg(Arg::with_name("EVALUATE") .long("evaluate") .help("Prints evaluated variables")) + .arg(Arg::with_name("HIGHLIGHT") + .long("highlight") + .help("Highlight echoed recipe lines in bold")) .arg(Arg::with_name("JUSTFILE") .long("justfile") .takes_value(true) @@ -338,6 +341,7 @@ pub fn app() { let options = RunOptions { dry_run: matches.is_present("DRY-RUN"), evaluate: matches.is_present("EVALUATE"), + highlight: matches.is_present("HIGHLIGHT"), overrides: overrides, quiet: matches.is_present("QUIET"), shell: matches.value_of("SHELL"), diff --git a/src/lib.rs b/src/lib.rs index fa65899..f4d941b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -424,8 +424,11 @@ impl<'a> Recipe<'a> { if options.dry_run || options.verbose || !((quiet_command ^ self.quiet) || options.quiet) { - warn!("{}", command); + let highlight = maybe_highlight(options.highlight + && options.use_color.should_color_stderr()); + warn!("{}", highlight.paint(command)); } + if options.dry_run { continue; } @@ -1031,6 +1034,14 @@ fn maybe_bold(colors: bool) -> ansi_term::Style { } } +fn maybe_highlight(colors: bool) -> ansi_term::Style { + if colors { + ansi_term::Style::new().fg(ansi_term::Color::Cyan).bold() + } else { + ansi_term::Style::default() + } +} + impl<'a> Display for CompileError<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { use ErrorKind::*; @@ -1143,6 +1154,7 @@ struct Justfile<'a> { struct RunOptions<'a> { dry_run: bool, evaluate: bool, + highlight: bool, overrides: Map<&'a str, &'a str>, quiet: bool, shell: Option<&'a str>,