mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-06 22:40:58 +00:00
Support multiple file inputs
This commit is contained in:
parent
cca984017a
commit
47f1e306ab
2 changed files with 11 additions and 6 deletions
|
|
@ -53,7 +53,7 @@ Run it inside a repository with a `README.md` or specify a different Markdown
|
|||
file with
|
||||
|
||||
```
|
||||
lychee --input <yourfile.md>
|
||||
lychee <yourfile>
|
||||
```
|
||||
|
||||
## Thanks
|
||||
|
|
|
|||
15
src/main.rs
15
src/main.rs
|
|
@ -18,12 +18,12 @@ use reqwest::Url;
|
|||
|
||||
#[derive(Debug, Options)]
|
||||
struct LycheeOptions {
|
||||
#[options(free, help = "Input files")]
|
||||
inputs: Vec<String>,
|
||||
|
||||
#[options(help = "show help")]
|
||||
help: bool,
|
||||
|
||||
#[options(help = "Input file containing the links to check")]
|
||||
input: Option<String>,
|
||||
|
||||
#[options(help = "Verbose program output")]
|
||||
verbose: bool,
|
||||
|
||||
|
|
@ -100,8 +100,13 @@ async fn run(opts: LycheeOptions) -> Result<()> {
|
|||
opts.insecure,
|
||||
opts.verbose,
|
||||
)?;
|
||||
let md = fs::read_to_string(opts.input.unwrap_or_else(|| "README.md".into()))?;
|
||||
let links = extract_links(&md);
|
||||
|
||||
let mut links = HashSet::new();
|
||||
|
||||
for input in opts.inputs {
|
||||
let md = fs::read_to_string(input)?;
|
||||
links.extend(extract_links(&md));
|
||||
}
|
||||
|
||||
let futures: Vec<_> = links.iter().map(|l| checker.check(&l)).collect();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue