Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/configs/cache.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cache = true
max_age = "1d"
max_cache_age = "1d"
1 change: 1 addition & 0 deletions fixtures/configs/files_from/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://wikipedia.org
1 change: 1 addition & 0 deletions fixtures/configs/files_from/files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example.md
1 change: 1 addition & 0 deletions fixtures/configs/files_from/lychee.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
files_from = "files.txt"
1 change: 1 addition & 0 deletions fixtures/configs/invalid-key.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this_is_invalid = "this is purely fictional"
2 changes: 1 addition & 1 deletion fixtures/configs/invalid.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
max_age = 42my
max_cache_age = 42my
2 changes: 1 addition & 1 deletion fixtures/configs/smoketest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ exclude_link_local = false
exclude_loopback = false

# Exclude all mail addresses from checking.
exclude_mail = false
include_mail = false
4 changes: 2 additions & 2 deletions lychee-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ fn read_lines(file: &File) -> Result<Vec<String>> {
.collect())
}

/// Merge all provided config options into one This includes a potential config
/// file, command-line- and environment variables
/// Merge all provided config options into one.
/// This includes a potential config file, command-line- and environment variables
fn load_config() -> Result<LycheeOptions> {
let mut opts = LycheeOptions::parse();

Expand Down
46 changes: 24 additions & 22 deletions lychee-bin/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,27 +335,6 @@ NOTE: Use `--` to separate inputs from options that allow multiple arguments."
)]
raw_inputs: Vec<String>,

/// Read input filenames from the given file or stdin (if path is '-').
#[arg(
long = "files-from",
value_name = "PATH",
long_help = "Read input filenames from the given file or stdin (if path is '-').

This is useful when you have a large number of inputs that would be
cumbersome to specify on the command line directly.

Examples:
lychee --files-from list.txt
find . -name '*.md' | lychee --files-from -
echo 'README.md' | lychee --files-from -

File Format:
Each line should contain one input (file path, URL, or glob pattern).
Lines starting with '#' are treated as comments and ignored.
Empty lines are also ignored."
)]
files_from: Option<PathBuf>,

/// Configuration file to use
#[arg(short, long = "config")]
#[arg(help = HELP_MSG_CONFIG_FILE)]
Expand All @@ -374,7 +353,7 @@ impl LycheeOptions {
let mut all_inputs = self.raw_inputs.clone();

// If --files-from is specified, read inputs from the file
if let Some(files_from_path) = &self.files_from {
if let Some(files_from_path) = &self.config.files_from {
let files_from = FilesFrom::try_from(files_from_path.as_path())
.context("Cannot read inputs from --files-from")?;
all_inputs.extend(files_from.inputs);
Expand Down Expand Up @@ -407,7 +386,29 @@ where
/// The main configuration for lychee
#[allow(clippy::struct_excessive_bools)]
#[derive(Parser, Debug, Deserialize, Clone, Default)]
#[serde(deny_unknown_fields)]
pub(crate) struct Config {
/// Read input filenames from the given file or stdin (if path is '-').
#[arg(
long = "files-from",
value_name = "PATH",
long_help = "Read input filenames from the given file or stdin (if path is '-').

This is useful when you have a large number of inputs that would be
cumbersome to specify on the command line directly.

Examples:
lychee --files-from list.txt
find . -name '*.md' | lychee --files-from -
echo 'README.md' | lychee --files-from -

File Format:
Each line should contain one input (file path, URL, or glob pattern).
Lines starting with '#' are treated as comments and ignored.
Empty lines are also ignored."
)]
files_from: Option<PathBuf>,

/// Verbose program output
#[clap(flatten)]
#[serde(default = "verbosity")]
Expand Down Expand Up @@ -953,6 +954,7 @@ impl Config {
exclude_private: false,
extensions: FileType::default_extensions(),
fallback_extensions: Vec::<String>::new(),
files_from: None,
format: StatsFormat::default(),
generate: None,
glob_ignore_case: false,
Expand Down
Loading