diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f542732..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,34 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: rust:1.36 - steps: - - checkout - # Load cargo target from cache if possible. - # Multiple caches are used to increase the chance of a cache hit. - - restore_cache: - keys: - - v2-cargo-cache-{{ arch }}-{{ .Branch }} - - v2-cargo-cache-{{ arch }} - - # Show versions - - run: rustc --version && cargo --version - - # Build - - run: cargo build - - run: cargo build --features logging - - # Run tests - - run: cargo test - - - save_cache: - key: v2-cargo-cache-{{ arch }}-{{ .Branch }} - paths: - - target - - /usr/local/cargo - - save_cache: - key: v2-cargo-cache-{{ arch }} - paths: - - target - - /usr/local/cargo diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d4eaf19 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +on: + push: + schedule: + - cron: '30 3 * * 2' + +name: CI + +jobs: + + test: + name: run tests + strategy: + matrix: + platform: [ubuntu-latest, macos-latest, windows-latest] + rust: [1.36.0, stable] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - name: Build with default features + uses: actions-rs/cargo@v1 + with: + command: build + - name: Build with all features + uses: actions-rs/cargo@v1 + with: + command: build + args: --all-features + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features + + clippy: + name: run clippy lints + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.36.0 + components: clippy + override: true + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d804029..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: rust -os: osx -rust: - - 1.36.0 - - stable -cache: cargo -script: cargo test 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 3bfc42f..30ae93b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ ![teal deer](deer.png) -|Crate|Linux|macOS|Windows| -|:---:|:---:|:---:|:-----:| -|[![Crates.io][crates-io-badge]][crates-io]|[![Circle CI][circle-ci-badge]][circle-ci]|[![Travis CI][travis-ci-badge]][travis-ci]|Should work™| +|Crate|CI (Linux/macOS/Windows)| +|:---:|:---:| +|[![Crates.io][crates-io-badge]][crates-io]|[![GitHub CI][github-actions-badge]][github-actions]| A very fast implementation of [tldr](https://github.com/tldr-pages/tldr) in Rust: Simplified, example based and community-driven man pages. @@ -193,6 +193,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 @@ -242,9 +244,7 @@ Thanks to @SShrike for coming up with the name "tealdeer"! [tldr-node-client]: https://github.com/tldr-pages/tldr-node-client -[circle-ci]: https://circleci.com/gh/dbrgn/tealdeer/tree/master -[circle-ci-badge]: https://circleci.com/gh/dbrgn/tealdeer/tree/master.svg?style=shield -[travis-ci]: https://travis-ci.org/dbrgn/tealdeer -[travis-ci-badge]: https://travis-ci.org/dbrgn/tealdeer.svg?branch=master +[github-actions]: https://github.com/dbrgn/tealdeer/actions?query=branch%3Amaster +[github-actions-badge]: https://github.com/dbrgn/tealdeer/workflows/CI/badge.svg [crates-io]: https://crates.io/crates/tealdeer [crates-io-badge]: https://img.shields.io/crates/v/tealdeer.svg diff --git a/src/main.rs b/src/main.rs index 9c78790..d2c00f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,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; @@ -85,8 +86,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 { @@ -139,6 +141,7 @@ fn print_page(path: &Path, enable_markdown: bool, enable_styles: bool) -> Result } /// Set up display pager +#[cfg(not(target_os = "windows"))] fn configure_pager(args: &Args, enable_styles: bool) { // Flags have precedence if args.flag_pager { @@ -164,6 +167,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 {