U6TQX5Z2NF6GX3SRLUBQGCZ7WAXNYMWWZ2YMADUSG4EWVKNV2BIAC
JRFPXWID6GZNSXG3DA3E4TZR6X5V3JJ3GZOO774WFMZS5ZH5BIMQC
6U42MTEZTINWUU2KLJLQW33ZBZXKTHPTF6TMEG56TO642CQDZQMQC
FDEVV5NGUMTEULP25EFYFZEVICWYLGV7XMED25PNKD36DL4NA46AC
AAXP2534BWX2ZUDZZHUMLYDBMGFGUH32CNRA3KOLER3JKOIJUZLAC
QL6K2ZM35B3NIXEMMCJWUSFXOBQHAGXRDMO7ID5DCKTJH4QJVY7QC
EUZFFJSOWV4PXDFFPDAFBHFUUMOFEU6ST7JH57YYRRR2SEOXLN6QC
2K7JLB4Z7BS5VFNWD4DO3MKYU7VNPA5MTVHVSDI3FQZ5ICM6XM6QC
GLRGFBCWZYQEP6BG2IXYMXVZ5ETPWKNA2YJSIRHBCAAOAHJYT2YQC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
ZRUPLBBTT4S6S7A3LOAHG4ONYEGPA5CFO4L2XBCNFKK45MWX3BDAC
6F6AAHK4M2IVS23TVISR5OJSTZXUSEKLOP5BMM7SUHYG2FQNTSGQC
OU6JOR3CDZTH2H3NTGMV3WDIAWPD3VEJI7JRY3VJ7LPDR3QOA52QC
F2S6XETO6DQ4447O4WPAHISGTBRVWW2WZYJ633KKYWWYKW5GXBPQC
5BB266P6HPUGYEVR7QNNOA62EFPYPUYJ3UMLE5J3LLYMSUWXANIQC
Q4SVMHAEZQQCBFGPJMWS5H4VXB2HFQREZ3AWGOHFWHLFARUQVPBAC
/// Respect the `pager` key/value pair in both the user's repository config, and their global config.
/// The global configuration requires no additional arguments, but the other two are optional to cover
/// cases in which that information is not available. Users can also disable the pager by not setting
/// the `PAGER` environment variable.
fn pager() -> bool {
if let Ok(less) = std::process::Command::new("less")
.args(&["--version"])
.output()
fn pager(repo_config_pager: Option<&crate::config::Choice>) -> bool {
if let Some(crate::config::Choice::Never) = repo_config_pager {
return false;
} else if let Some(crate::config::Choice::Never) = crate::config::Global::load()
.ok()
.and_then(|(global, _)| global.pager)
let regex = regex::bytes::Regex::new("less ([0-9]+)").unwrap();
if let Some(caps) = regex.captures(&less.stdout) {
if std::str::from_utf8(&caps[1])
.unwrap()
.parse::<usize>()
.unwrap()
>= 530
{
pager::Pager::with_pager("less -RF").setup();
return true;
} else {
pager::Pager::new().setup();
return false;
} else if let Ok(pager_env_var) = std::env::var("PAGER") {
if !pager_env_var.is_empty() {
match pager_env_var.as_str() {
"less" => {
if let Ok(pager_output) = std::process::Command::new(pager_env_var)
.args(&["--version"])
.output()
{
let regex = regex::bytes::Regex::new("less ([0-9]+)").unwrap();
if let Some(caps) = regex.captures(&pager_output.stdout) {
if std::str::from_utf8(&caps[1])
.unwrap()
.parse::<usize>()
.unwrap()
>= 530
{
pager::Pager::with_pager("less -RF").setup();
return true;
} else {
pager::Pager::new().setup();
}
}
}
}
owise => {
pager::Pager::with_pager(owise).setup();
}
_ => {
super::pager();
LogIterator::try_from(self)?.for_each(|entry| {
match write!(&mut stdout, "{}", entry) {
Ok(_) => Ok(()),
Err(e) if e.kind() == std::io::ErrorKind::BrokenPipe => Ok(()),
Err(e) => Err(e),
}
})?
}
_ => log_iter.for_each(|entry| match write!(&mut stdout, "{}", entry) {
Ok(_) => Ok(()),
Err(e) if e.kind() == std::io::ErrorKind::BrokenPipe => Ok(()),
Err(e) => Err(e),
})?,