Add option to highlight echoed recipe lines (#190)
Using bold and cyan, for visibility.
This commit is contained in:
parent
9fce455851
commit
1990c58a21
@ -115,6 +115,9 @@ pub fn app() {
|
|||||||
.arg(Arg::with_name("EVALUATE")
|
.arg(Arg::with_name("EVALUATE")
|
||||||
.long("evaluate")
|
.long("evaluate")
|
||||||
.help("Prints evaluated variables"))
|
.help("Prints evaluated variables"))
|
||||||
|
.arg(Arg::with_name("HIGHLIGHT")
|
||||||
|
.long("highlight")
|
||||||
|
.help("Highlight echoed recipe lines in bold"))
|
||||||
.arg(Arg::with_name("JUSTFILE")
|
.arg(Arg::with_name("JUSTFILE")
|
||||||
.long("justfile")
|
.long("justfile")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
@ -338,6 +341,7 @@ pub fn app() {
|
|||||||
let options = RunOptions {
|
let options = RunOptions {
|
||||||
dry_run: matches.is_present("DRY-RUN"),
|
dry_run: matches.is_present("DRY-RUN"),
|
||||||
evaluate: matches.is_present("EVALUATE"),
|
evaluate: matches.is_present("EVALUATE"),
|
||||||
|
highlight: matches.is_present("HIGHLIGHT"),
|
||||||
overrides: overrides,
|
overrides: overrides,
|
||||||
quiet: matches.is_present("QUIET"),
|
quiet: matches.is_present("QUIET"),
|
||||||
shell: matches.value_of("SHELL"),
|
shell: matches.value_of("SHELL"),
|
||||||
|
14
src/lib.rs
14
src/lib.rs
@ -424,8 +424,11 @@ impl<'a> Recipe<'a> {
|
|||||||
if options.dry_run
|
if options.dry_run
|
||||||
|| options.verbose
|
|| options.verbose
|
||||||
|| !((quiet_command ^ self.quiet) || options.quiet) {
|
|| !((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 {
|
if options.dry_run {
|
||||||
continue;
|
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> {
|
impl<'a> Display for CompileError<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
use ErrorKind::*;
|
use ErrorKind::*;
|
||||||
@ -1143,6 +1154,7 @@ struct Justfile<'a> {
|
|||||||
struct RunOptions<'a> {
|
struct RunOptions<'a> {
|
||||||
dry_run: bool,
|
dry_run: bool,
|
||||||
evaluate: bool,
|
evaluate: bool,
|
||||||
|
highlight: bool,
|
||||||
overrides: Map<&'a str, &'a str>,
|
overrides: Map<&'a str, &'a str>,
|
||||||
quiet: bool,
|
quiet: bool,
|
||||||
shell: Option<&'a str>,
|
shell: Option<&'a str>,
|
||||||
|
Loading…
Reference in New Issue
Block a user