Skip to content

Improve configuration example#631

Merged
mre merged 5 commits intolycheeverse:masterfrom
vpereira01:improv-config-example
May 31, 2022
Merged

Improve configuration example#631
mre merged 5 commits intolycheeverse:masterfrom
vpereira01:improv-config-example

Conversation

@vpereira01
Copy link
Copy Markdown
Contributor

@vpereira01 vpereira01 commented May 31, 2022

Fixes #630

Easy test ./lychee -c lychee.example.toml -- README.md

cache = true

# TODO
# Error: invalid type: string "2d", expected struct Duration for key `max_cache_age`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. Yeah that's something we should fix. I think max_cache_age should be Into<Duration> instead of Duration. And maybe we need an impl From<String> for Duration to handle that case or usehuman_time. I can look into this, but for now it's fine to keep it in there.

headers = []

# TODO # Remap URI matching pattern to different URI
remap = [ "https://example.com http://example.invalid" ]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can support a nicer syntax for remapping similar to #547 (comment):

[[remap]]
pattern = "^../../issues"
replacement = "https://github.com/usnistgov/OSCAL/issues"

[[remap]]
pattern = "https://example.com"
replacement = "https://example.net"

Let's tackle that once this PR got merged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the example! :-p

I did try this re the linked CI/CD work I did on the repo (where #547 (comment) came from) and still had some issues. Will follow up later and try to work through understanding how to do the first example with the current syntax, or even the proposed syntax, in a follow-up issue.

Sorry for the delay.


# TODO
# Error: invalid type: unit variant, expected newtype variant for key `base`
# base = "https://example.com"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, don't know what's going on but it has something to do with the variants here:

pub enum Base {
/// Local file path pointing to root directory
Local(PathBuf),
/// Remote URL pointing to a website homepage
Remote(Url),
}

There is a TryFrom<&str>, which I though would take care of it, but that's incorrect.
We can also tackle that later.

@mre
Copy link
Copy Markdown
Member

mre commented May 31, 2022

Thanks for the draft. Added a few comments. 👍

@vpereira01 vpereira01 marked this pull request as ready for review May 31, 2022 15:59
@mre
Copy link
Copy Markdown
Member

mre commented May 31, 2022

Added a smoketest which tests all config options (except output, which would create a nasty temp file). Not perfect, but it's a step forward.
Once this pipeline passes this should be good to merge.

I'm not sure if we should keep all options in the example config enabled. The idea is that users would jump in and enable whatever they need at that moment and leave the rest to default. It's fine for now but we might change it in the future.

@mre mre merged commit d48a327 into lycheeverse:master May 31, 2022
@mre
Copy link
Copy Markdown
Member

mre commented May 31, 2022

Nicely done. Thanks for your contribution @vpereira01. 🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Outdated lychee.example.toml and hard to use

3 participants