1
1
mirror of https://github.com/casey/just.git synced 2024-11-24 04:38:25 +03:00

Add option to highlight echoed recipe lines (#190)

Using bold and cyan, for visibility.
This commit is contained in:
Casey Rodarmor 2017-04-25 23:39:34 -07:00 committed by GitHub
parent 9fce455851
commit 1990c58a21
2 changed files with 17 additions and 1 deletions

View File

@ -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"),

View File

@ -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>,