Skip to content

Commit

Permalink
allow less to be piped to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashiidobe committed Nov 7, 2021
1 parent 480e1d2 commit 8cf96bd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 20 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
# DONE: Compiles
- { target: x86_64-unknown-freebsd , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
- { target: x86_64-unknown-illumos , os: ubuntu-20.04, use-cross: true }
# - { target: x86_64-unknown-illumos , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
- { target: arm-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
Expand All @@ -81,19 +81,19 @@ jobs:
- { target: x86_64-unknown-netbsd , os: ubuntu-20.04, use-cross: true }
# Tier 2
# DONE: Compiles
- { target: aarch64-apple-ios , os: macos-11 }
# - { target: aarch64-apple-ios , os: macos-11 }
# DONE: Compiles
- { target: aarch64-apple-ios-sim , os: macos-11 }
# - { target: aarch64-apple-ios-sim , os: macos-11 }
# TODO: needs cc
# - { target: aarch64-fuchsia , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
- { target: aarch64-linux-android , os: ubuntu-20.04, use-cross: true }
# - { target: aarch64-linux-android , os: ubuntu-20.04, use-cross: true }
# TODO: needs cc
# - { target: aarch64-unknown-none-softfloat , os: ubuntu-20.04, use-cross: true }
# TODO: needs cc
# - { target: aarch64-unknown-none , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
- { target: arm-linux-androideabi , os: ubuntu-20.04, use-cross: true }
# - { target: arm-linux-androideabi , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
- { target: arm-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
Expand All @@ -107,7 +107,7 @@ jobs:
# DONE: Compiles
- { target: armv5te-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true }
# DONE: Compiles
- { target: armv7-linux-androideabi , os: ubuntu-20.04, use-cross: true }
# - { target: armv7-linux-androideabi , os: ubuntu-20.04, use-cross: true }
# TODO: needs docker image for cross
# - { target: armv7-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true }
# TODO: needs docker image for cross
Expand Down Expand Up @@ -377,6 +377,7 @@ jobs:
case ${{ matrix.job.target }} in
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
aarch64-unknown-linux-musl) sudo apt-get -y update ; sudo apt-get -y install musl-dev ;;
i686-pc-windows-gnu) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;;
i686-pc-windows-msvc) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;;
i586-pc-windows-msvc) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;;
Expand All @@ -390,11 +391,13 @@ jobs:
echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV
echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV
- name: Install Rust toolchain
shell: bash
run: |
rustup default nightly
rustup target add ${{ matrix.job.target }}
uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.job.target }}
profile: minimal
toolchain: stable

- name: Show version information (Rust, cargo, GCC)
shell: bash
Expand Down
14 changes: 13 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
cargo-features = ["strip"]

[package]
name = "rless"
version = "0.0.4"
version = "0.0.5"
edition = "2018"
default-run = "rless"
readme = "README.md"
Expand All @@ -17,6 +15,7 @@ crossterm = "0.20.0"
futures = "0.3.17"
minus = { version = "4.0.2", features = ["async_std_lib", "search", "static_output"] }
man = { version = "0.3.0", optional = true }
atty = "0.2.14"

[[bin]]
name = "man"
Expand All @@ -25,7 +24,3 @@ required-features = ["build_deps"]

[features]
build_deps = ["man"]

[profile.release]
strip = "symbols"

2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Add color to terminal
# Check if output is a terminal. If so, show fancy output, otherwise, work like cat.
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
use rless::*;
use atty::Stream;
use std::fs::read_to_string;

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let (filename, pager) = arg_parser()?;
read_file(filename, pager.finish()).await
if atty::is(Stream::Stdout) {
read_file(filename, pager.finish()).await;

Check warning on line 9 in src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

unused `std::result::Result` that must be used

warning: unused `std::result::Result` that must be used --> src/main.rs:9:6 | 9 | read_file(filename, pager.finish()).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled = note: `#[warn(unused_must_use)]` on by default help: use `let _ = ...` to ignore the resulting value | 9 | let _ = read_file(filename, pager.finish()).await; | +++++++

Check warning on line 9 in src/main.rs

View workflow job for this annotation

GitHub Actions / Check

unused `Result` that must be used

Check warning on line 9 in src/main.rs

View workflow job for this annotation

GitHub Actions / Check

unused `Result` that must be used

Check warning on line 9 in src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Output

unused `std::result::Result` that must be used

warning: unused `std::result::Result` that must be used --> src/main.rs:9:6 | 9 | read_file(filename, pager.finish()).await; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled = note: `#[warn(unused_must_use)]` on by default help: use `let _ = ...` to ignore the resulting value | 9 | let _ = read_file(filename, pager.finish()).await; | +++++++
std::process::exit(0);
}
let res = read_to_string(filename);
println!("{}", res.unwrap());
Ok(())
}

0 comments on commit 8cf96bd

Please sign in to comment.