From d349974089dc26a0f385a94a2d654537586a7f55 Mon Sep 17 00:00:00 2001 From: Alexander Karlis Date: Fri, 11 Sep 2020 22:54:47 -0400 Subject: [PATCH] updated PR based on comments --- src/bin/bat/app.rs | 5 +++-- src/bin/bat/clap_app.rs | 13 ++++++++----- src/bin/bat/main.rs | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index 24cc7ac8..9e4d0f75 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -165,7 +165,7 @@ impl App { // There's no point in wrapping when this is the case. WrappingMode::NoWrapping }, - colored_output: self.matches.is_present("always-decorations") + colored_output: self.matches.is_present("force-colorization") || match self.matches.value_of("color") { Some("always") => true, Some("never") => false, @@ -178,7 +178,7 @@ impl App { loop_through: !(self.interactive_output || self.matches.value_of("color") == Some("always") || (self.matches.value_of("decorations") == Some("always") - || self.matches.is_present("always-decorations"))), + || self.matches.is_present("force-colorization"))), tab_width: self .matches .value_of("tabs") @@ -288,6 +288,7 @@ impl App { fn style_components(&self) -> Result { let matches = &self.matches; + println!("{:#?}", matches); Ok(StyleComponents( if matches.value_of("decorations") == Some("never") { HashSet::new() diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index f6775ab5..385d017b 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -258,13 +258,16 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> { ), ) .arg( - Arg::with_name("always-decorations") + Arg::with_name("force-colorization") + .long("force-colorization") .short("f") - .alias("always-decor") - .overrides_with("always-decorations") - .hidden(true) + .conflicts_with("color") + .conflicts_with("decorations") + .overrides_with("force-colorization") .hidden_short_help(true) - .help("Alias for '--decorations=always --color=always'") + .long_help("Alias for '--decorations=always --color=always'. This is useful \ + if the output of bat is piped to another program, but you want \ + to keep the colorization/decorations.") ) .arg( Arg::with_name("paging") diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 65129fa7..373712b3 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -209,6 +209,7 @@ fn run() -> Result { } else { let inputs = vec![Input::ordinary_file(OsStr::new("cache"))]; let config = app.config(&inputs)?; + println!("{:#?}", config); run_controller(inputs, &config) } @@ -217,6 +218,8 @@ fn run() -> Result { let inputs = app.inputs()?; let config = app.config(&inputs)?; + println!("{:#?}", config); + if app.matches.is_present("list-languages") { list_languages(&config)?; Ok(true)