mirror of
https://github.com/Hopiu/lychee.git
synced 2026-03-16 20:50:25 +00:00
* renamed `base` to `base_url` (fixes #1607) * fixed readme * added warning for deprecated `--base` * Update lychee.example.toml * Update fixtures/configs/smoketest.toml
This commit is contained in:
parent
50687175d1
commit
d6bbf85145
7 changed files with 38 additions and 12 deletions
|
|
@ -484,8 +484,11 @@ Options:
|
|||
|
||||
[default: get]
|
||||
|
||||
-b, --base <BASE>
|
||||
Base URL or website root directory to check relative URLs e.g. <https://example.com> or `/path/to/public`
|
||||
--base <BASE>
|
||||
Deprecated; use `--base-url` instead
|
||||
|
||||
-b, --base-url <BASE_URL>
|
||||
Base URL used to resolve relative URLs during link checking Example: <https://example.com>
|
||||
|
||||
--root-dir <ROOT_DIR>
|
||||
Root path to use when checking absolute local links, must be an absolute path
|
||||
|
|
|
|||
2
fixtures/configs/smoketest.toml
vendored
2
fixtures/configs/smoketest.toml
vendored
|
|
@ -80,7 +80,7 @@ remap = [
|
|||
]
|
||||
|
||||
# Base URL or website root directory to check relative URLs.
|
||||
base = "https://example.com"
|
||||
base_url = "https://example.com"
|
||||
|
||||
# HTTP basic auth support. This will be the username and password passed to the
|
||||
# authorization HTTP header. See
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub(crate) fn create(cfg: &Config, cookie_jar: Option<&Arc<CookieStoreMutex>>) -
|
|||
|
||||
ClientBuilder::builder()
|
||||
.remaps(remaps)
|
||||
.base(cfg.base.clone())
|
||||
.base(cfg.base_url.clone())
|
||||
.includes(includes)
|
||||
.excludes(excludes)
|
||||
.exclude_all_private(cfg.exclude_all_private)
|
||||
|
|
|
|||
|
|
@ -177,6 +177,13 @@ fn load_config() -> Result<LycheeOptions> {
|
|||
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.");
|
||||
}
|
||||
|
||||
// TODO: Remove this warning and the parameter with 1.0
|
||||
if opts.config.base.is_some() {
|
||||
warn!(
|
||||
"WARNING: `--base` is deprecated and will soon be removed; use `--base-url` instead."
|
||||
);
|
||||
}
|
||||
|
||||
// Load excludes from file
|
||||
for path in &opts.config.exclude_file {
|
||||
let file = File::open(path)?;
|
||||
|
|
@ -288,7 +295,18 @@ 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_dir.clone(), opts.config.base.clone())?
|
||||
// TODO: Remove this section after `--base` got removed with 1.0
|
||||
let base = match (opts.config.base.clone(), opts.config.base_url.clone()) {
|
||||
(None, None) => None,
|
||||
(Some(base), None) => Some(base),
|
||||
(None, Some(base_url)) => Some(base_url),
|
||||
(Some(_base), Some(base_url)) => {
|
||||
warn!("WARNING: Both, `--base` and `--base-url` are set. Using `base-url` and ignoring `--base` (as it's deprecated).");
|
||||
Some(base_url)
|
||||
}
|
||||
};
|
||||
|
||||
let mut collector = Collector::new(opts.config.root_dir.clone(), base)?
|
||||
.skip_missing_inputs(opts.config.skip_missing)
|
||||
.skip_hidden(!opts.config.hidden)
|
||||
.skip_ignored(!opts.config.no_ignore)
|
||||
|
|
|
|||
|
|
@ -449,11 +449,16 @@ separated list of accepted status codes. This example will accept 200, 201,
|
|||
#[serde(default = "method")]
|
||||
pub(crate) method: String,
|
||||
|
||||
/// Base URL or website root directory to check relative URLs
|
||||
/// e.g. <https://example.com> or `/path/to/public`
|
||||
/// Deprecated; use `--base-url` instead
|
||||
#[arg(long, value_parser = parse_base)]
|
||||
#[serde(skip)]
|
||||
pub(crate) base: Option<Base>,
|
||||
|
||||
/// Base URL used to resolve relative URLs during link checking
|
||||
/// Example: <https://example.com>
|
||||
#[arg(short, long, value_parser= parse_base)]
|
||||
#[serde(default)]
|
||||
pub(crate) base: Option<Base>,
|
||||
pub(crate) base_url: Option<Base>,
|
||||
|
||||
/// Root path to use when checking absolute local links,
|
||||
/// must be an absolute path
|
||||
|
|
@ -568,7 +573,7 @@ impl Config {
|
|||
timeout: DEFAULT_TIMEOUT_SECS;
|
||||
retry_wait_time: DEFAULT_RETRY_WAIT_TIME_SECS;
|
||||
method: DEFAULT_METHOD;
|
||||
base: None;
|
||||
base_url: None;
|
||||
basic_auth: None;
|
||||
skip_missing: false;
|
||||
include_verbatim: false;
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ mod cli {
|
|||
let dir = fixtures_path().join("resolve_paths");
|
||||
|
||||
cmd.arg("--offline")
|
||||
.arg("--base")
|
||||
.arg("--base-url")
|
||||
.arg(&dir)
|
||||
.arg(dir.join("index.html"))
|
||||
.env_clear()
|
||||
|
|
@ -419,7 +419,7 @@ mod cli {
|
|||
cmd.arg("--offline")
|
||||
.arg("--root-dir")
|
||||
.arg("/resolve_paths")
|
||||
.arg("--base")
|
||||
.arg("--base-url")
|
||||
.arg(&dir)
|
||||
.arg(dir.join("resolve_paths").join("index.html"))
|
||||
.env_clear()
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ header = ["name=value", "other=value"]
|
|||
remap = ["https://example.com http://example.invalid"]
|
||||
|
||||
# Base URL or website root directory to check relative URLs.
|
||||
base = "https://example.com"
|
||||
base_url = "https://example.com"
|
||||
|
||||
# HTTP basic auth support. This will be the username and password passed to the
|
||||
# authorization HTTP header. See
|
||||
|
|
|
|||
Loading…
Reference in a new issue