Support multiple file inputs

This commit is contained in:
Matthias Endler 2020-08-13 23:01:30 +02:00
parent cca984017a
commit 47f1e306ab
2 changed files with 11 additions and 6 deletions

View file

@ -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

View file

@ -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();