mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-22 15:53:29 +01:00
Use matches
macro
This commit is contained in:
parent
304ee1489c
commit
23fd11e806
25
src/pager.rs
25
src/pager.rs
@ -98,18 +98,21 @@ pub(crate) fn get_pager(config_pager: Option<&str>) -> Result<Option<Pager>, Par
|
|||||||
Some((bin, args)) => {
|
Some((bin, args)) => {
|
||||||
let kind = PagerKind::from_bin(bin);
|
let kind = PagerKind::from_bin(bin);
|
||||||
|
|
||||||
let use_less_instead = match (&source, &kind) {
|
// Is false if the given expression does not match any of the
|
||||||
// 'more' and 'most' do not supports colors; automatically use 'less' instead
|
// patterns; this ensures 'less' is never silently used if BAT_PAGER
|
||||||
// if the problematic pager came from the generic PAGER env var
|
// or --pager has been specified.
|
||||||
(PagerSource::EnvVarPager, PagerKind::More) => true,
|
let use_less_instead = matches!(
|
||||||
(PagerSource::EnvVarPager, PagerKind::Most) => true,
|
(&source, &kind),
|
||||||
|
// 'more' and 'most' do not supports colors; automatically use
|
||||||
|
// 'less' instead if the problematic pager came from the
|
||||||
|
// generic PAGER env var
|
||||||
|
(PagerSource::EnvVarPager, PagerKind::More)
|
||||||
|
| (PagerSource::EnvVarPager, PagerKind::Most)
|
||||||
|
|
||||||
// If PAGER=bat, silently use 'less' instead to prevent recursion ...
|
// If PAGER=bat, silently use 'less' instead to prevent
|
||||||
(PagerSource::EnvVarPager, PagerKind::Bat) => true,
|
// recursion ...
|
||||||
|
| (PagerSource::EnvVarPager, PagerKind::Bat)
|
||||||
// Never silently use less if BAT_PAGER or --pager has been specified
|
);
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Some(if use_less_instead {
|
Ok(Some(if use_less_instead {
|
||||||
let no_args = vec![];
|
let no_args = vec![];
|
||||||
|
Loading…
Reference in New Issue
Block a user