When this code was written, the client specification instructed clients
that they MUST download pages from the tldr.sh domain. However, this
domain was deprecated and shut down in December 2025.
The Apple computer operating system was renamed from "OS X" to "macOS"
in 2016. We should accept "macos" instead of "osx" in all our CLI APIs,
and the docs should also mention this alias instead of "osx".
For backwards compatibility and for compatibility with the tldr client
specification, we should still accept "osx" though.
This makes it compliant with the client spec.
The `-p` flag was previously used for the pager, using the pager now
requires using the long flag (`--pager`). Alternatively the pager can be
configured through the config file.
This commit also renames OsType to PlatformType.
Squashed commits:
- chore: wipe only pages instead of entire cache dir
- fix: only delete dir if it exists
- chore: try to make variable names less confusing
- chore: display error as well
Instead of downloading the GitHub repository archive, download the pages
from the official URL instead.
Squashed commits:
- chore: use recommended tldr-pages archive url
- chore: extract pages dir to constant
- chore(deps): install zip crate
- feat: use zip crate to unpack archive
- chore(deps): drop flate2
- Create explicit CacheFreshness enum
- Do not exit inside `check_cache` function, this prevents further
actions if the cache isn't found
Co-authored-by: invakid404 <invakid404@riseup.net>
Changes the serde configuration of the `RawConfig` struct to utilize
a custom `Default` implementation to initialize new objects. This
implementation contains the default style set as it was previously
provided through the implementation of `RawConfig::new()`.
This allows to utilize the default configuration until the user
overwrites the related `RawStyleConfig` field, e.g. the description
highlighting.
Fixes#149.
As someone reading this file for the first time, I would want to see the
only public and most general function first and find the specifics
further down instead of having to look for the "module entry" first.
This moves `print_page` from `main.rs` and `print_snippet` from
`formatter.rs` into a new file `output.rs`. To decompose `print_snippet`
from `print_lines`, the latter now takes the `yield_snippet` callable as
an argument (similar to how the helper methods got a hold of it). In
order for this to work, callers have to provide a function that is
generic over all possible snippet lifetimes.
This includes
- adding the `HighlightingSnippet` enum as a common ground for
highlighting and printing code to communicate
- decomposing `print_lines` accordingly
- clearing up `highlight_code_segment` (previously `highlight_command`)
- adding unit tests (now that they can reason about
`HighlightingSnippet`s instead of having to output on the integration
test level
- Change logging messages to go to stderr
- Updated tests to expect these messages in stderr instead of stdout
- Changed test_markdown_rendering to no longer rely on the tldr pages repo