Skip to content

Commit ca834f1

Browse files
committed
Also dump excluded links
This is a minimally invasive version, which allows to grep for `[excluded]`. The reason for exclusion would require more work and it's debatable if it adds any value, because it might make grepping harder and the source of exclusion is easily deducatable from the commandline parameters or the `.lycheeignore` file. Fixes #587.
1 parent 4690cc0 commit ca834f1

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

lychee-bin/src/commands/dump.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ where
1818
while let Some(request) = requests.next().await {
1919
let request = request?;
2020

21-
if params.client.is_excluded(&request.uri) {
22-
continue;
23-
}
24-
2521
// Avoid panic on broken pipe.
2622
// See https://github.com/rust-lang/rust/issues/46016
2723
// This can occur when piping the output of lychee
2824
// to another program like `grep`.
29-
if let Err(e) = write(&request, params.cfg.verbose) {
25+
26+
let excluded = params.client.is_excluded(&request.uri);
27+
let verbose = params.cfg.verbose;
28+
29+
if excluded && !verbose {
30+
continue;
31+
}
32+
if let Err(e) = write(&request, verbose, excluded) {
3033
if e.kind() != io::ErrorKind::BrokenPipe {
3134
eprintln!("{e}");
3235
return Ok(ExitCode::UnexpectedFailure);
@@ -38,13 +41,17 @@ where
3841
}
3942

4043
/// Dump request to stdout
41-
/// Only print source in verbose mode. This way the normal link output
42-
/// can be fed into another tool without data mangling.
43-
fn write(request: &Request, verbose: bool) -> io::Result<()> {
44-
let output = if verbose {
44+
fn write(request: &Request, verbose: bool, excluded: bool) -> io::Result<()> {
45+
let request = if verbose {
46+
// Only print source in verbose mode. This way the normal link output
47+
// can be fed into another tool without data mangling.
4548
request.to_string()
4649
} else {
4750
request.uri.to_string()
4851
};
49-
writeln!(io::stdout(), "{}", output)
52+
if excluded {
53+
writeln!(io::stdout(), "{} [excluded]", request)
54+
} else {
55+
writeln!(io::stdout(), "{}", request)
56+
}
5057
}

0 commit comments

Comments
 (0)