Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d6bbf85

Browse files
authoredFeb 16, 2025··
renamed base to base_url (fixes #1607) (#1629)
* renamed `base` to `base_url` (fixes #1607) * fixed readme * added warning for deprecated `--base` * Update lychee.example.toml * Update fixtures/configs/smoketest.toml
1 parent 5068717 commit d6bbf85

File tree

7 files changed

+38
-12
lines changed

7 files changed

+38
-12
lines changed
 

‎README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,11 @@ Options:
484484
485485
[default: get]
486486
487-
-b, --base <BASE>
488-
Base URL or website root directory to check relative URLs e.g. <https://example.com> or `/path/to/public`
487+
--base <BASE>
488+
Deprecated; use `--base-url` instead
489+
490+
-b, --base-url <BASE_URL>
491+
Base URL used to resolve relative URLs during link checking Example: <https://example.com>
489492
490493
--root-dir <ROOT_DIR>
491494
Root path to use when checking absolute local links, must be an absolute path

‎fixtures/configs/smoketest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ remap = [
8080
]
8181

8282
# Base URL or website root directory to check relative URLs.
83-
base = "https://example.com"
83+
base_url = "https://example.com"
8484

8585
# HTTP basic auth support. This will be the username and password passed to the
8686
# authorization HTTP header. See

‎lychee-bin/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) fn create(cfg: &Config, cookie_jar: Option<&Arc<CookieStoreMutex>>) -
5555

5656
ClientBuilder::builder()
5757
.remaps(remaps)
58-
.base(cfg.base.clone())
58+
.base(cfg.base_url.clone())
5959
.includes(includes)
6060
.excludes(excludes)
6161
.exclude_all_private(cfg.exclude_all_private)

‎lychee-bin/src/main.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ fn load_config() -> Result<LycheeOptions> {
177177
warn!("WARNING: `--exclude-mail` is deprecated and will soon be removed; E-Mail is no longer checked by default. Use `--include-mail` to enable E-Mail checking.");
178178
}
179179

180+
// TODO: Remove this warning and the parameter with 1.0
181+
if opts.config.base.is_some() {
182+
warn!(
183+
"WARNING: `--base` is deprecated and will soon be removed; use `--base-url` instead."
184+
);
185+
}
186+
180187
// Load excludes from file
181188
for path in &opts.config.exclude_file {
182189
let file = File::open(path)?;
@@ -288,7 +295,18 @@ fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> {
288295
async fn run(opts: &LycheeOptions) -> Result<i32> {
289296
let inputs = opts.inputs()?;
290297

291-
let mut collector = Collector::new(opts.config.root_dir.clone(), opts.config.base.clone())?
298+
// TODO: Remove this section after `--base` got removed with 1.0
299+
let base = match (opts.config.base.clone(), opts.config.base_url.clone()) {
300+
(None, None) => None,
301+
(Some(base), None) => Some(base),
302+
(None, Some(base_url)) => Some(base_url),
303+
(Some(_base), Some(base_url)) => {
304+
warn!("WARNING: Both, `--base` and `--base-url` are set. Using `base-url` and ignoring `--base` (as it's deprecated).");
305+
Some(base_url)
306+
}
307+
};
308+
309+
let mut collector = Collector::new(opts.config.root_dir.clone(), base)?
292310
.skip_missing_inputs(opts.config.skip_missing)
293311
.skip_hidden(!opts.config.hidden)
294312
.skip_ignored(!opts.config.no_ignore)

‎lychee-bin/src/options.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,16 @@ separated list of accepted status codes. This example will accept 200, 201,
449449
#[serde(default = "method")]
450450
pub(crate) method: String,
451451

452-
/// Base URL or website root directory to check relative URLs
453-
/// e.g. <https://example.com> or `/path/to/public`
452+
/// Deprecated; use `--base-url` instead
453+
#[arg(long, value_parser = parse_base)]
454+
#[serde(skip)]
455+
pub(crate) base: Option<Base>,
456+
457+
/// Base URL used to resolve relative URLs during link checking
458+
/// Example: <https://example.com>
454459
#[arg(short, long, value_parser= parse_base)]
455460
#[serde(default)]
456-
pub(crate) base: Option<Base>,
461+
pub(crate) base_url: Option<Base>,
457462

458463
/// Root path to use when checking absolute local links,
459464
/// must be an absolute path
@@ -568,7 +573,7 @@ impl Config {
568573
timeout: DEFAULT_TIMEOUT_SECS;
569574
retry_wait_time: DEFAULT_RETRY_WAIT_TIME_SECS;
570575
method: DEFAULT_METHOD;
571-
base: None;
576+
base_url: None;
572577
basic_auth: None;
573578
skip_missing: false;
574579
include_verbatim: false;

‎lychee-bin/tests/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ mod cli {
383383
let dir = fixtures_path().join("resolve_paths");
384384

385385
cmd.arg("--offline")
386-
.arg("--base")
386+
.arg("--base-url")
387387
.arg(&dir)
388388
.arg(dir.join("index.html"))
389389
.env_clear()
@@ -419,7 +419,7 @@ mod cli {
419419
cmd.arg("--offline")
420420
.arg("--root-dir")
421421
.arg("/resolve_paths")
422-
.arg("--base")
422+
.arg("--base-url")
423423
.arg(&dir)
424424
.arg(dir.join("resolve_paths").join("index.html"))
425425
.env_clear()

‎lychee.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ header = ["name=value", "other=value"]
7575
remap = ["https://example.com http://example.invalid"]
7676

7777
# Base URL or website root directory to check relative URLs.
78-
base = "https://example.com"
78+
base_url = "https://example.com"
7979

8080
# HTTP basic auth support. This will be the username and password passed to the
8181
# authorization HTTP header. See

0 commit comments

Comments
 (0)
Please sign in to comment.