mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-01 18:34:47 +00:00
This change deprecates `--exclude-file` as it was ambiguous. Instead, `--exclude-path` was introduced to support excluding paths to files and directories that should not be checked. Furthermore, `.lycheeignore` is now the only way to exclude URL patterns.
36 lines
1 KiB
Rust
36 lines
1 KiB
Rust
use lychee_lib::{Collector, Input, InputSource, Result};
|
|
use reqwest::Url;
|
|
use std::path::PathBuf;
|
|
use tokio_stream::StreamExt;
|
|
|
|
#[tokio::main]
|
|
#[allow(clippy::trivial_regex)]
|
|
async fn main() -> Result<()> {
|
|
// Collect all links from the following inputs
|
|
let inputs = vec![
|
|
Input {
|
|
source: InputSource::RemoteUrl(Box::new(
|
|
Url::parse("https://github.com/lycheeverse/lychee").unwrap(),
|
|
)),
|
|
file_type_hint: None,
|
|
excluded_paths: None,
|
|
},
|
|
Input {
|
|
source: InputSource::FsPath(PathBuf::from("fixtures/TEST.md")),
|
|
file_type_hint: None,
|
|
excluded_paths: None,
|
|
},
|
|
];
|
|
|
|
let links = Collector::new(None) // base
|
|
.skip_missing_inputs(false) // don't skip missing inputs? (default=false)
|
|
.use_html5ever(false) // use html5ever for parsing? (default=false)
|
|
.collect_links(inputs) // base url or directory
|
|
.await
|
|
.collect::<Result<Vec<_>>>()
|
|
.await?;
|
|
|
|
dbg!(links);
|
|
|
|
Ok(())
|
|
}
|