Skip to content

Commit

Permalink
Rename --root-path to --root-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Dec 6, 2024
1 parent 0bb19b9 commit b767b36
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 67 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ Options:
-b, --base <BASE>
Base URL or website root directory to check relative URLs e.g. <https://example.com> or `/path/to/public`
--root-path <ROOT_PATH>
--root-dir <ROOT_DIR>
Root path to use when checking absolute local links
--basic-auth <BASIC_AUTH>
Expand Down
2 changes: 1 addition & 1 deletion lychee-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> {
async fn run(opts: &LycheeOptions) -> Result<i32> {
let inputs = opts.inputs()?;

let mut collector = Collector::new(opts.config.root_path.clone(), opts.config.base.clone())
let mut collector = Collector::new(opts.config.root_dir.clone(), opts.config.base.clone())
.skip_missing_inputs(opts.config.skip_missing)
.skip_hidden(!opts.config.hidden)
.skip_ignored(!opts.config.no_ignore)
Expand Down
2 changes: 1 addition & 1 deletion lychee-bin/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ separated list of accepted status codes. This example will accept 200, 201,
/// Root path to use when checking absolute local links
#[arg(long)]
#[serde(default)]
pub(crate) root_path: Option<PathBuf>,
pub(crate) root_dir: Option<PathBuf>,

/// Basic authentication support. E.g. `http://example.com username:password`
#[arg(long)]
Expand Down
10 changes: 5 additions & 5 deletions lychee-bin/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,13 @@ mod cli {
}

#[test]
fn test_resolve_paths_from_root_path() {
fn test_resolve_paths_from_root_dir() {
let mut cmd = main_command();
let dir = fixtures_path().join("resolve_paths_from_root_path");
let dir = fixtures_path().join("resolve_paths_from_root_dir");

cmd.arg("--offline")
.arg("--include-fragments")
.arg("--root-path")
.arg("--root-dir")
.arg(&dir)
.arg(dir.join("nested").join("index.html"))
.env_clear()
Expand All @@ -412,12 +412,12 @@ mod cli {
}

#[test]
fn test_resolve_paths_from_root_path_and_base_url() {
fn test_resolve_paths_from_root_dir_and_base_url() {
let mut cmd = main_command();
let dir = fixtures_path();

cmd.arg("--offline")
.arg("--root-path")
.arg("--root-dir")
.arg("/resolve_paths")
.arg("--base")
.arg(&dir)
Expand Down
20 changes: 10 additions & 10 deletions lychee-lib/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct Collector {
skip_hidden: bool,
include_verbatim: bool,
use_html5ever: bool,
root_path: Option<PathBuf>,
root_dir: Option<PathBuf>,
base: Option<Base>,
}

Expand All @@ -35,7 +35,7 @@ impl Default for Collector {
use_html5ever: false,
skip_hidden: true,
skip_ignored: true,
root_path: None,
root_dir: None,
base: None,
}
}
Expand All @@ -44,15 +44,15 @@ impl Default for Collector {
impl Collector {
/// Create a new collector with an empty cache
#[must_use]
pub const fn new(root_path: Option<PathBuf>, base: Option<Base>) -> Self {
pub const fn new(root_dir: Option<PathBuf>, base: Option<Base>) -> Self {
Collector {
basic_auth_extractor: None,
skip_missing_inputs: false,
include_verbatim: false,
use_html5ever: false,
skip_hidden: true,
skip_ignored: true,
root_path,
root_dir,
base,
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Collector {
})
.flatten()
.par_then_unordered(None, move |(content, base)| {
let root_path = self.root_path.clone();
let root_dir = self.root_dir.clone();
let basic_auth_extractor = self.basic_auth_extractor.clone();
async move {
let content = content?;
Expand All @@ -146,7 +146,7 @@ impl Collector {
let requests = request::create(
uris,
&content.source,
root_path.as_ref(),
root_dir.as_ref(),
base.as_ref(),
basic_auth_extractor.as_ref(),
);
Expand Down Expand Up @@ -175,20 +175,20 @@ mod tests {
// Helper function to run the collector on the given inputs
async fn collect(
inputs: Vec<Input>,
root_path: Option<PathBuf>,
root_dir: Option<PathBuf>,
base: Option<Base>,
) -> HashSet<Uri> {
let responses = Collector::new(root_path, base).collect_links(inputs);
let responses = Collector::new(root_dir, base).collect_links(inputs);
responses.map(|r| r.unwrap().uri).collect().await
}

// Helper function for collecting verbatim links
async fn collect_verbatim(
inputs: Vec<Input>,
root_path: Option<PathBuf>,
root_dir: Option<PathBuf>,
base: Option<Base>,
) -> HashSet<Uri> {
let responses = Collector::new(root_path, base)
let responses = Collector::new(root_dir, base)
.include_verbatim(true)
.collect_links(inputs);
responses.map(|r| r.unwrap().uri).collect().await
Expand Down
Loading

0 comments on commit b767b36

Please sign in to comment.