1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-28 17:51:44 +00:00

Add --strip-ansi option

This commit is contained in:
Ethan P.
2024-06-10 21:05:20 -07:00
parent c264ecd26b
commit 70ff93d238
8 changed files with 155 additions and 1 deletions
+10
View File
@@ -7,6 +7,7 @@ use crate::{
clap_app,
config::{get_args_from_config_file, get_args_from_env_opts_var, get_args_from_env_vars},
};
use bat::StripAnsiMode;
use clap::ArgMatches;
use console::Term;
@@ -242,6 +243,15 @@ impl App {
4
},
),
strip_ansi: match self
.matches
.get_one::<String>("strip-ansi")
.map(|s| s.as_str())
{
Some("never") => StripAnsiMode::Never,
Some("always") => StripAnsiMode::Always,
_ => unreachable!("other values for --strip-ansi are not allowed"),
},
theme: self
.matches
.get_one::<String>("theme")
+12
View File
@@ -402,6 +402,18 @@ pub fn build_app(interactive_output: bool) -> Command {
.long_help("Set the maximum number of consecutive empty lines to be printed.")
.hide_short_help(true)
)
.arg(
Arg::new("strip-ansi")
.long("strip-ansi")
.overrides_with("strip-ansi")
.value_name("when")
.value_parser(["always", "never"])
.default_value("never")
.hide_default_value(true)
.help("Strip colors from the input (always, *never*)")
.long_help("Specify when to strip ANSI escape sequences from the input. Possible values: always, *never*.")
.hide_short_help(true)
)
.arg(
Arg::new("style")
.long("style")