From 47f1e306abbbc1681f81698747436eee4e99a244 Mon Sep 17 00:00:00 2001 From: Matthias Endler Date: Thu, 13 Aug 2020 23:01:30 +0200 Subject: [PATCH] Support multiple file inputs --- README.md | 2 +- src/main.rs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dc137b9..f9ab8ef 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Run it inside a repository with a `README.md` or specify a different Markdown file with ``` -lychee --input +lychee ``` ## Thanks diff --git a/src/main.rs b/src/main.rs index f0b2256..8ad07f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,12 +18,12 @@ use reqwest::Url; #[derive(Debug, Options)] struct LycheeOptions { + #[options(free, help = "Input files")] + inputs: Vec, + #[options(help = "show help")] help: bool, - #[options(help = "Input file containing the links to check")] - input: Option, - #[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();