Disable pager feature on Windows

This commit is contained in:
Danilo Bargen 2020-01-22 23:20:56 +01:00
commit bcdfd5e9a8
3 changed files with 14 additions and 2 deletions

View file

@ -25,6 +25,7 @@ use std::time::Duration;
use ansi_term::Color;
use app_dirs::AppInfo;
use docopt::Docopt;
#[cfg(not(target_os = "windows"))]
use pager::Pager;
use serde_derive::Deserialize;
@ -83,8 +84,9 @@ To render a local file (for testing):
$ tldr --render /path/to/file.md
";
const ARCHIVE_URL: &str = "https://github.com/tldr-pages/tldr/archive/master.tar.gz";
const PAGER_COMMAND: &str = "less -R";
const MAX_CACHE_AGE: Duration = Duration::from_secs(2_592_000); // 30 days
#[cfg(not(target_os = "windows"))]
const PAGER_COMMAND: &str = "less -R";
#[derive(Debug, Deserialize)]
struct Args {
@ -129,6 +131,7 @@ fn print_page(path: &Path, enable_styles: bool) -> Result<(), String> {
}
/// Set up display pager
#[cfg(not(target_os = "windows"))]
fn configure_pager(args: &Args, enable_styles: bool) {
// Flags have precedence
if args.flag_pager {
@ -154,6 +157,11 @@ fn configure_pager(args: &Args, enable_styles: bool) {
}
}
#[cfg(target_os = "windows")]
fn configure_pager(_args: &Args, _enable_styles: bool) {
eprintln!("Warning: -p / --pager flag not available on Windows!");
}
/// Check the cache for freshness
fn check_cache(args: &Args, cache: &Cache) {
if !args.flag_update {