Skip to content

Commit 8cf96bd

Browse files
committed
allow less to be piped to a file
1 parent 480e1d2 commit 8cf96bd

File tree

5 files changed

+38
-20
lines changed

5 files changed

+38
-20
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
# DONE: Compiles
7171
- { target: x86_64-unknown-freebsd , os: ubuntu-20.04, use-cross: true }
7272
# DONE: Compiles
73-
- { target: x86_64-unknown-illumos , os: ubuntu-20.04, use-cross: true }
73+
# - { target: x86_64-unknown-illumos , os: ubuntu-20.04, use-cross: true }
7474
# DONE: Compiles
7575
- { target: arm-unknown-linux-musleabihf , os: ubuntu-20.04, use-cross: true }
7676
# DONE: Compiles
@@ -81,19 +81,19 @@ jobs:
8181
- { target: x86_64-unknown-netbsd , os: ubuntu-20.04, use-cross: true }
8282
# Tier 2
8383
# DONE: Compiles
84-
- { target: aarch64-apple-ios , os: macos-11 }
84+
# - { target: aarch64-apple-ios , os: macos-11 }
8585
# DONE: Compiles
86-
- { target: aarch64-apple-ios-sim , os: macos-11 }
86+
# - { target: aarch64-apple-ios-sim , os: macos-11 }
8787
# TODO: needs cc
8888
# - { target: aarch64-fuchsia , os: ubuntu-20.04, use-cross: true }
8989
# DONE: Compiles
90-
- { target: aarch64-linux-android , os: ubuntu-20.04, use-cross: true }
90+
# - { target: aarch64-linux-android , os: ubuntu-20.04, use-cross: true }
9191
# TODO: needs cc
9292
# - { target: aarch64-unknown-none-softfloat , os: ubuntu-20.04, use-cross: true }
9393
# TODO: needs cc
9494
# - { target: aarch64-unknown-none , os: ubuntu-20.04, use-cross: true }
9595
# DONE: Compiles
96-
- { target: arm-linux-androideabi , os: ubuntu-20.04, use-cross: true }
96+
# - { target: arm-linux-androideabi , os: ubuntu-20.04, use-cross: true }
9797
# DONE: Compiles
9898
- { target: arm-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true }
9999
# DONE: Compiles
@@ -107,7 +107,7 @@ jobs:
107107
# DONE: Compiles
108108
- { target: armv5te-unknown-linux-musleabi , os: ubuntu-20.04, use-cross: true }
109109
# DONE: Compiles
110-
- { target: armv7-linux-androideabi , os: ubuntu-20.04, use-cross: true }
110+
# - { target: armv7-linux-androideabi , os: ubuntu-20.04, use-cross: true }
111111
# TODO: needs docker image for cross
112112
# - { target: armv7-unknown-linux-gnueabi , os: ubuntu-20.04, use-cross: true }
113113
# TODO: needs docker image for cross
@@ -377,6 +377,7 @@ jobs:
377377
case ${{ matrix.job.target }} in
378378
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
379379
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
380+
aarch64-unknown-linux-musl) sudo apt-get -y update ; sudo apt-get -y install musl-dev ;;
380381
i686-pc-windows-gnu) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;;
381382
i686-pc-windows-msvc) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;;
382383
i586-pc-windows-msvc) echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH ;;
@@ -390,11 +391,13 @@ jobs:
390391
echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV
391392
echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV
392393
394+
393395
- name: Install Rust toolchain
394-
shell: bash
395-
run: |
396-
rustup default nightly
397-
rustup target add ${{ matrix.job.target }}
396+
uses: actions-rs/toolchain@v1
397+
with:
398+
target: ${{ matrix.job.target }}
399+
profile: minimal
400+
toolchain: stable
398401

399402
- name: Show version information (Rust, cargo, GCC)
400403
shell: bash

Cargo.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
cargo-features = ["strip"]
2-
31
[package]
42
name = "rless"
5-
version = "0.0.4"
3+
version = "0.0.5"
64
edition = "2018"
75
default-run = "rless"
86
readme = "README.md"
@@ -17,6 +15,7 @@ crossterm = "0.20.0"
1715
futures = "0.3.17"
1816
minus = { version = "4.0.2", features = ["async_std_lib", "search", "static_output"] }
1917
man = { version = "0.3.0", optional = true }
18+
atty = "0.2.14"
2019

2120
[[bin]]
2221
name = "man"
@@ -25,7 +24,3 @@ required-features = ["build_deps"]
2524

2625
[features]
2726
build_deps = ["man"]
28-
29-
[profile.release]
30-
strip = "symbols"
31-

TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Add color to terminal
1+
# Check if output is a terminal. If so, show fancy output, otherwise, work like cat.

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
use rless::*;
2+
use atty::Stream;
3+
use std::fs::read_to_string;
24

35
#[async_std::main]
46
async fn main() -> Result<(), Box<dyn std::error::Error>> {
57
let (filename, pager) = arg_parser()?;
6-
read_file(filename, pager.finish()).await
8+
if atty::is(Stream::Stdout) {
9+
read_file(filename, pager.finish()).await;
10+
std::process::exit(0);
11+
}
12+
let res = read_to_string(filename);
13+
println!("{}", res.unwrap());
14+
Ok(())
715
}

0 commit comments

Comments
 (0)