Skip to content

Commit 8fd34a7

Browse files
authored
Add no check (dump links only) flag (#99)
1 parent bcc06ae commit 8fd34a7

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ USAGE:
176176
lychee [FLAGS] [OPTIONS] [--] [inputs]...
177177
178178
FLAGS:
179+
--dump Don't perform any link checking. Instead, dump all the links extracted from inputs that
180+
would be checked
179181
-E, --exclude-all-private Exclude all private IPs from checking.
180182
Equivalent to `--exclude-private --exclude-link-local --exclude-loopback`
181183
--exclude-link-local Exclude link-local IP address range from checking

lychee-bin/src/main.rs

+9
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ async fn run(cfg: &Config, inputs: Vec<Input>) -> Result<i32> {
205205
.await
206206
.map_err(|e| anyhow!(e))?;
207207

208+
if cfg.dump {
209+
for link in links {
210+
if !client.filtered(&link.uri) {
211+
println!("{}", link);
212+
}
213+
}
214+
return Ok(ExitCode::Success as i32);
215+
}
216+
208217
let pb = if cfg.no_progress {
209218
None
210219
} else {

lychee-bin/src/options.rs

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ pub(crate) struct Config {
124124
#[serde(default)]
125125
pub(crate) no_progress: bool,
126126

127+
/// Don't perform any link checking.
128+
/// Instead, dump all the links extracted from inputs that would be checked
129+
#[structopt(long)]
130+
#[serde(default)]
131+
pub(crate) dump: bool,
132+
127133
/// Maximum number of allowed redirects
128134
#[structopt(short, long, default_value = &MAX_REDIRECTS_STR)]
129135
#[serde(default = "max_redirects")]

lychee-lib/src/client.rs

+5
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ impl Client {
198198
Ok(Response::new(uri, status, source))
199199
}
200200

201+
/// Check if the given URI is filtered by the client
202+
pub fn filtered(&self, uri: &Uri) -> bool {
203+
self.filter.is_excluded(uri)
204+
}
205+
201206
pub async fn check_website(&self, uri: &Uri) -> Status {
202207
let mut retries: i64 = 3;
203208
let mut wait: u64 = 1;

0 commit comments

Comments
 (0)