Skip to content

Commit 67df0fa

Browse files
committed
Fix #1938 comments
1 parent 0e128a9 commit 67df0fa

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

lychee-bin/src/commands/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ where
5959
accept,
6060
));
6161

62-
let hide_bar = params.cfg.no_progress || params.stdin_input;
62+
let hide_bar = params.cfg.no_progress || params.is_stdin_input;
6363
let level = params.cfg.verbose().log_level();
6464

6565
let progress = Progress::new("Extracting links", hide_bar, level, &params.cfg.mode());

lychee-bin/src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) struct CommandParams<S: futures::Stream<Item = Result<Request, Reques
2222
pub(crate) cache: Cache,
2323
pub(crate) requests: S,
2424
pub(crate) cfg: Config,
25-
pub(crate) stdin_input: bool,
25+
pub(crate) is_stdin_input: bool,
2626
}
2727

2828
/// Creates a writer that outputs to a file or stdout.

lychee-bin/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#![deny(missing_docs)]
6060

6161
use std::fs::{self, File};
62-
use std::io::{self, BufRead, BufReader, ErrorKind, IsTerminal};
62+
use std::io::{self, BufRead, BufReader, ErrorKind, IsTerminal, stdin};
6363
use std::path::PathBuf;
6464

6565
use anyhow::{Context, Error, Result};
@@ -311,11 +311,11 @@ async fn run(opts: &LycheeOptions) -> Result<i32> {
311311
//
312312
// When stdin is piped (`cat links.txt | lychee -`), `is_terminal()` returns
313313
// false, so the progress bar is shown normally.
314-
let stdin_input = inputs.len() == 1
314+
let is_stdin_input = inputs.len() == 1
315315
&& inputs
316316
.iter()
317317
.any(|input| matches!(input.source, lychee_lib::InputSource::Stdin))
318-
&& std::io::stdin().is_terminal();
318+
&& stdin().is_terminal();
319319

320320
// TODO: Remove this section after `--base` got removed with 1.0
321321
let base = match (opts.config.base.clone(), opts.config.base_url.clone()) {
@@ -384,7 +384,7 @@ async fn run(opts: &LycheeOptions) -> Result<i32> {
384384
cache,
385385
requests,
386386
cfg: opts.config.clone(),
387-
stdin_input,
387+
is_stdin_input,
388388
};
389389

390390
let exit_code = if opts.config.dump {

lychee-lib/src/types/input/input.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{ErrorKind, LycheeResult};
1313
use async_stream::try_stream;
1414
use futures::stream::{Stream, StreamExt};
1515
use log::debug;
16+
use std::io::IsTerminal;
1617
use std::path::{Path, PathBuf};
1718
use tokio::io::{AsyncReadExt, stdin};
1819

@@ -271,7 +272,9 @@ impl Input {
271272
let mut content = String::new();
272273
let mut stdin = stdin();
273274

274-
debug!("Reading content from stdin"); // useful info when nothing piped and process blocks
275+
if std::io::stdin().is_terminal() {
276+
debug!("Reading content from stdin"); // useful info when nothing piped and process blocks
277+
}
275278
stdin.read_to_string(&mut content).await?;
276279

277280
let input_content = InputContent {

0 commit comments

Comments
 (0)