updated PR based on comments

This commit is contained in:
Alexander Karlis 2020-09-11 22:54:47 -04:00 committed by David Peter
parent ccdea6a429
commit d349974089
3 changed files with 14 additions and 7 deletions

View File

@ -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<StyleComponents> {
let matches = &self.matches;
println!("{:#?}", matches);
Ok(StyleComponents(
if matches.value_of("decorations") == Some("never") {
HashSet::new()

View File

@ -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")

View File

@ -209,6 +209,7 @@ fn run() -> Result<bool> {
} 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<bool> {
let inputs = app.inputs()?;
let config = app.config(&inputs)?;
println!("{:#?}", config);
if app.matches.is_present("list-languages") {
list_languages(&config)?;
Ok(true)