Commit graph

107 commits

Author SHA1 Message Date
Matthias Endler
2272ad1a48 Show progress bar by default (can be disabled with --no-progress) 2021-02-21 17:19:32 +01:00
Matthias Endler
09ceda5931 Rearrange and extend tests 2021-02-21 17:00:44 +01:00
Matthias Endler
14d47d9108 Initialize exclude using Default and field overwriting 2021-02-21 16:55:26 +01:00
Matthias Endler
fa1952dd98 cleanup 2021-02-21 16:42:09 +01:00
Matthias Endler
1f6cbd1aa4 Add excludes to filter module 2021-02-21 16:35:13 +01:00
Matthias Endler
9fe1244f8c Add expect for website function in test_utils 2021-02-21 16:34:46 +01:00
Matthias Endler
ca71a5df2d Add filter module that encapsulates includes/excludes 2021-02-21 16:34:22 +01:00
Matthias Endler
e00cdbf1ae example.com -> example.org 2021-02-21 16:33:33 +01:00
Matthias Endler
8d165a3cda Add support and tests for .markdown files 2021-02-21 09:37:49 +01:00
Matthias Endler
678dc4f18e Add support for colored output 2021-02-19 00:41:49 +01:00
Matthias Endler
a4b1609424 Improve progress visualization 2021-02-19 00:23:35 +01:00
Matthias Endler
1a95aa4a44 Format 2021-02-19 00:05:14 +01:00
Matthias Endler
69e3b2cffc Formatting 2021-02-18 23:33:26 +01:00
Matthias Endler
59c6093c8a Formatting 2021-02-18 23:33:14 +01:00
Matthias Endler
5226cd10aa Change exclude behavior to make includes more intuitive
Previously an include alone would not mean that only the included
patterns were checked. Only if an exclude was given as well,
the includes would make a difference. Now, the includes on their
own will work as expected.
Moved the exlude methods into the Exclude mod.
Also changed the order of exclude tests to do the fast lookup
ones before the regex ones.
Added tests to guarantee behavior in the future.
2021-02-18 21:42:00 +01:00
Matthias Endler
fe5cea1de3 Add doc-comment tests 2021-02-18 11:14:00 +01:00
Matthias Endler
16cd67331a Add simple, standalone client
Adds a new function `lychee::check()`, which removes
a lot of boilerplate for simple cases. Adjusted the code,
tests, and documentation.
The downside is that `check` now returns a Result, so
we have to use `?` to get to the response. That's because
we have to account for the case where the given string is
not a valid URI.
2021-02-18 01:32:48 +01:00
Matthias Endler
867a9ac31a Collapse output conditions 2021-02-17 12:32:17 +01:00
Matthias Endler
8e5799a041 Always display output in the expected format
Even on stdout we print JSON now if `--format json` is set.
The reason is that not outputting any JSON when the format
is requested can be unintuitive. It is also great for debugging
purposes before sending the output to a file
with the `--output` argument.
2021-02-17 12:22:31 +01:00
Matthias Endler
0872604f18 Clean up program output
Use response.to_string instead of custom status_message function
2021-02-17 12:20:51 +01:00
Matthias Endler
751deeb9b9 Show failure reason in status output
Use HashSet<Response> instead of Vec<Uri> for status output
2021-02-17 12:18:56 +01:00
Matthias Endler
8173e9927f Be more explicit about supported output formats 2021-02-17 12:17:45 +01:00
Matthias Endler
d16e4fa1bc Implement Serialize and Display for Status 2021-02-17 12:13:49 +01:00
Matthias Endler
b7bdfa6890 Add helper methods for Status 2021-02-17 12:13:32 +01:00
Matthias Endler
8e15bfb0be Implement Display and Serialize for Response 2021-02-17 12:12:37 +01:00
Matthias Endler
7859cb17c6 Cleanup unused deserialize 2021-02-17 12:11:51 +01:00
Matthias Endler
d9adfbf80f Add support for serializing input 2021-02-17 12:11:28 +01:00
Matthias Endler
d6b960368a Adjust tests 2021-02-17 12:10:57 +01:00
Matthias Endler
4faf40cfba Move check functions closer together 2021-02-17 01:01:43 +01:00
Matthias Endler
e859f1290e Correct matches for fail_map and add test 2021-02-16 01:21:45 +01:00
Matthias Endler
428df23c1c Fix lints and test on Linux 2021-02-16 00:53:01 +01:00
Matthias Endler
54e1d3e078 Simplify tests 2021-02-16 00:35:59 +01:00
Matthias Endler
4bec47904e Show input source in status output
If an error occurs during link checking,
it is important to know where the error occured.
Therefore the request and response objects now contain a the input
source as a field. This makes error tracking easier.
2021-02-16 00:15:14 +01:00
Matthias
702909c4ab
Mailto support (#138)
* Add mailto suport and use try_from for parsing URLs
* Cleanup and document code
2021-02-12 10:25:33 +01:00
Matthias
0b148bf5e6
Exclude e-mails from being checked (#137)
This can be useful in CI environments where SMTP is not allowed.
2021-02-10 11:58:04 +01:00
Paweł Romanowski
836f557829
Ensure destructors are ran before std::process::exit (#134)
See comments in code for more details.
2021-02-08 11:04:01 +01:00
Matthias
a50c04fffe
Add hint about separating inputs from options with -- (fixes #113) (#119) 2021-01-17 17:01:06 +01:00
Paweł Romanowski
aeab85da16
Use html5ever for HTML link extraction (#98) 2021-01-08 16:41:13 +01:00
dependabot-preview[bot]
a3ad492c0b
Update dependencies (reqwest 0.11 and tokio 1.0) (#51)
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Matthias Endler <matthias-endler@gmx.net>
2021-01-07 00:10:58 +01:00
Paweł Romanowski
cd00fa643e
Fix HTML parsing for non-closed elements like <link> (#92)
* Fix HTML parsing for non-closed elements like <link>

The XML parser we use requires all tags to be closed by default,
and if they aren't (like HTML5 <link> elements), it simply gives up
on further parsing.  This change makes it ignore such issues.

Also uncover a bug with the current parser (it simply won't parse
elements like `<script defer src="..."></script>`) -- e.g. elements
with no attribute values.

The XML parser is an XML parser and will have to be replaced with
HTML aware parser in the future.

* Add check for empty elements

* Update extract.rs

Co-authored-by: Matthias <matthias-endler@gmx.net>
2021-01-03 17:32:13 +01:00
Paweł Romanowski
fa9c5ea2cf
Run clippy for all targets, including tests (#93)
The test code should also be linted.
2021-01-03 16:41:19 +01:00
Matthias
a78e8318cd
Add (machine-readable) output file support (fixes #53)
For now we only support JSON.
I honestly don't know if it makes sense to include other formats.
For example, MD and HTML are not really
machine-readable. YAML is not
a great standard format for this use-case. Open for discussions, though.
2020-12-14 01:15:14 +01:00
Matthias
b7ab4abb0d
Make lychee usable as a library #13 (#46)
This splits up the code into a `lib` and a `bin`
to make the runtime usable from other crates.

Co-authored-by: Paweł Romanowski <pawroman@pawroman.dev>
2020-12-04 10:44:31 +01:00
Paweł Romanowski
1f787613d4
Add support for reading from stdin and make input handling more robust (closes #26)
* Adds a `skip_missing` flag
* Adds an `Input` enum to handle different types of inputs
2020-12-02 23:28:37 +01:00
Matthias Endler
68b574d85d Make README.md the default when no inputs are given
That used to be the case according to the docs,
but somehow we broke it while introducing some
changes.
2020-11-25 10:40:36 +01:00
Matthias
8294e47307
Properly announce lychee user agent (#38) 2020-11-25 10:11:02 +01:00
Matthias
b0f7a805ef
Use builder pattern and channels (fixes #12) (#33)
This implements a basic builder for the Checker struct as discussed in #12.
It is using derive_builder and uses a custom build method to instantiate the more elaborate fields like reqwest::Client.
It also adds deadpool and tokio::mpsc as dependencies to handle a pool of clients to query websites.
2020-11-24 21:30:06 +01:00
Matthias Endler
d0b7a64d0a Refactor and add documentation 2020-11-10 00:03:50 +01:00
Paweł Romanowski
326683f4eb
Make GITHUB_TOKEN optional (#22)
* Make GITHUB_TOKEN optional

This also makes the token possible to pass in from CLI args.

* Add missing test fixture file

* Normalize exit codes and GitHub checking behavior

The exit code is now defined as 1 for unexpected or config errors,
and 2 for link check failures.

GitHub checking behavior has been tweaked to generate errors if
a GitHub-specific check cannot be performed because of a missing
token.

* Remove short flag for github token
2020-10-26 23:31:31 +01:00
Milton Fabian Bastidas Guerra
2bf62e7709
Add support for basic auth #18 (#20)
[Issue #18](https://github.com/hello-rust/lychee/issues/18)
* Add headers crate to type headers and create auth header
* Add cmd param basic-auth to set property to the main
* Add simple test to test if with auth headres is no broken

Signed-off-by: FabianBG <f4b4g3@gmail.com>
2020-10-26 09:23:45 +01:00