Use colour to make errors more obvious

pull/907/head
Wilfred Hughes 2025-10-20 00:47:53 +07:00
parent ca95aaaa67
commit 86e31458fc
2 changed files with 13 additions and 2 deletions

@ -59,6 +59,7 @@ mod words;
#[macro_use]
extern crate log;
use crossterm::tty::IsTty as _;
use display::style::print_warning;
use log::info;
use options::FilePermissions;
@ -518,7 +519,12 @@ fn diff_conflicts_file(
if conflict_files.num_conflicts == 0 {
eprintln!(
"error: Difftastic requires two paths, or a single file with conflict markers {}.\n",
"{}: Difftastic requires two paths, or a single file with conflict markers {}.\n",
if std::io::stdout().is_tty() {
"error".red().bold().to_string()
} else {
"error".to_owned()
},
START_LHS_MARKER,
);

@ -958,7 +958,12 @@ pub(crate) fn parse_args() -> Mode {
_ => {
if !args.is_empty() {
eprintln!(
"error: Difftastic does not support being called with {} argument{}.\n",
"{}: Difftastic does not support being called with {} argument{}.\n",
if use_color {
"error".red().bold().to_string()
} else {
"error".to_owned()
},
args.len(),
if args.len() == 1 { "" } else { "s" }
);