From 2cd3de8b94726b69203a1dbcbcb96205c5db9ee8 Mon Sep 17 00:00:00 2001 From: xanonid Date: Fri, 16 Oct 2020 16:11:21 +0200 Subject: [PATCH] Use NO_COLOR env variable check also for help screen --- src/app.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index b5dee4a..685f184 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,10 +1,17 @@ use clap::{crate_version, App, AppSettings, Arg}; pub fn build_app() -> App<'static, 'static> { + let clap_color_setting = + if std::env::var_os("NO_COLOR").is_none() { + AppSettings::ColoredHelp + } else { + AppSettings::ColorNever + }; + let mut app = App::new("fd") .version(crate_version!()) .usage("fd [FLAGS/OPTIONS] [] [...]") - .setting(AppSettings::ColoredHelp) + .setting(clap_color_setting) .setting(AppSettings::DeriveDisplayOrder) .after_help( "Note: `fd -h` prints a short and concise overview while `fd --help` gives all \