mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-09 09:49:10 +02:00
Disable pager feature on Windows
This commit is contained in:
parent
7b3f7a6470
commit
bcdfd5e9a8
3 changed files with 14 additions and 2 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
10
src/main.rs
10
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue