mirror of
https://github.com/sharkdp/bat.git
synced 2025-03-13 22:28:26 +00:00
refactor: Replace multiple_occurrences
This commit is contained in:
parent
e8e1c1d6c9
commit
50bb924ee3
@ -84,7 +84,7 @@ impl App {
|
||||
Some("never") => PagingMode::Never,
|
||||
Some("auto") | None => {
|
||||
// If we have -pp as an option when in auto mode, the pager should be disabled.
|
||||
let extra_plain = self.matches.occurrences_of("plain") > 1;
|
||||
let extra_plain = self.matches.get_count("plain") > 1;
|
||||
if extra_plain || self.matches.is_present("no-paging") {
|
||||
PagingMode::Never
|
||||
} else if inputs.iter().any(Input::is_stdin) {
|
||||
@ -297,7 +297,7 @@ impl App {
|
||||
HashSet::new()
|
||||
} else if matches.is_present("number") {
|
||||
[StyleComponent::LineNumbers].iter().cloned().collect()
|
||||
} else if matches.is_present("plain") {
|
||||
} else if 0 < matches.get_count("plain") {
|
||||
[StyleComponent::Plain].iter().cloned().collect()
|
||||
} else {
|
||||
let env_style_components: Option<Vec<StyleComponent>> = env::var("BAT_STYLE")
|
||||
|
@ -1,5 +1,6 @@
|
||||
use clap::{
|
||||
crate_name, crate_version, value_parser, AppSettings, Arg, ArgGroup, ColorChoice, Command,
|
||||
crate_name, crate_version, value_parser, AppSettings, Arg, ArgAction, ArgGroup, ColorChoice,
|
||||
Command,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::env;
|
||||
@ -73,7 +74,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
|
||||
.overrides_with("number")
|
||||
.short('p')
|
||||
.long("plain")
|
||||
.multiple_occurrences(true)
|
||||
.action(ArgAction::Count)
|
||||
.help("Show plain style (alias for '--style=plain').")
|
||||
.long_help(
|
||||
"Only show plain style, no decorations. This is an alias for \
|
||||
@ -100,7 +101,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
|
||||
.long("highlight-line")
|
||||
.short('H')
|
||||
.takes_value(true)
|
||||
.multiple_occurrences(true)
|
||||
.action(ArgAction::Append)
|
||||
.value_name("N:M")
|
||||
.help("Highlight lines N through M.")
|
||||
.long_help(
|
||||
@ -117,7 +118,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
|
||||
Arg::new("file-name")
|
||||
.long("file-name")
|
||||
.takes_value(true)
|
||||
.multiple_occurrences(true)
|
||||
.action(ArgAction::Append)
|
||||
.value_name("name")
|
||||
.value_parser(value_parser!(PathBuf))
|
||||
.help("Specify the name to display for a file.")
|
||||
@ -337,7 +338,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
|
||||
Arg::new("map-syntax")
|
||||
.short('m')
|
||||
.long("map-syntax")
|
||||
.multiple_occurrences(true)
|
||||
.action(ArgAction::Append)
|
||||
.takes_value(true)
|
||||
.value_name("glob:syntax")
|
||||
.help("Use the specified syntax for files matching the glob pattern ('*.cpp:C++').")
|
||||
@ -352,7 +353,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
|
||||
)
|
||||
.arg(
|
||||
Arg::new("ignored-suffix")
|
||||
.multiple_occurrences(true)
|
||||
.action(ArgAction::Append)
|
||||
.takes_value(true)
|
||||
.long("ignored-suffix")
|
||||
.hide_short_help(true)
|
||||
@ -450,7 +451,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> {
|
||||
Arg::new("line-range")
|
||||
.long("line-range")
|
||||
.short('r')
|
||||
.multiple_occurrences(true)
|
||||
.action(ArgAction::Append)
|
||||
.takes_value(true)
|
||||
.value_name("N:M")
|
||||
.help("Only print the lines from N to M.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user