diff --git a/Cargo.toml b/Cargo.toml index 098d068..a28c728 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ docopt = "1" env_logger = { version = "0.7", optional = true } flate2 = "1" log = "0.4" -pager = "0.15" reqwest = "0.9.5" serde = "1.0.21" serde_derive = "1.0.21" @@ -30,6 +29,9 @@ toml = "0.5.1" walkdir = "2.0.1" xdg = "2.1.0" +[target.'cfg(not(windows))'.dependencies] +pager = "0.15" + [dev-dependencies] assert_cmd = "0.10" escargot = "0.3" diff --git a/README.md b/README.md index a8c29cb..7d61cd1 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,8 @@ Specifies whether the pager should be used by default or not (default `false`). When enabled, `less -R` is used as pager. To override the pager command used, set the `PAGER` environment variable. +NOTE: This feature is not available on Windows. + #### `compact` Set this to enforce more compact output, where empty lines are stripped out diff --git a/src/main.rs b/src/main.rs index f61efd3..7613528 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 {