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:
parent
9fce455851
commit
1990c58a21
@ -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"),
|
||||
|
14
src/lib.rs
14
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>,
|
||||
|
Loading…
Reference in New Issue
Block a user