Commit graph

68 commits

Author SHA1 Message Date
Danilo Bargen
f3d74850a8
Make clippy happy (#373) 2024-08-06 21:46:40 +00:00
Danilo Bargen
64f3fbbbc6 Apply clippy suggestions 2024-06-17 00:35:04 +02:00
K.B.Dharun Krishna
ee6d2418f1
Add BSD platform support and update workflows (#354) 2024-04-10 16:05:51 +02:00
Zacchary Dempsey-Plante
17c08f0261
Change custom page files to use a .md extension (#322)
* Change custom page files to use a `.md` extension.
* Add a breaking change warning to the documentation for the usage of custom pages.
* Add a temporary check for old custom pages to assist in the migration to the new naming convention.

Co-authored-by: Danilo Bargen <mail@dbrgn.ch>
2024-02-15 19:27:56 +00:00
JJ Style
9e1489bbc5
Allow querying multiple platforms (#300) 2023-08-27 21:52:20 +00:00
tveness
76d9d0bbda
Obey 1.67 clippy lints (#313) 2023-02-07 21:56:41 +01:00
Danilo Bargen
c44faf2b09 Lazy creation of cache directory 2022-10-01 12:18:44 +02:00
Danilo Bargen
d702a1fab6 Cache: Add pages_dir helper method
Additionally, rename `cache_dir` to `pages_dir` where terminology was
wrong.
2022-10-01 12:18:34 +02:00
Danilo Bargen
3e7dfb3c71 Cache: Make URL a parameter, not a field 2022-10-01 12:18:33 +02:00
Danilo Bargen
33f0f108d8 Allow overriding cache directory through config
- Config: Add `cache_dir` to `[directories]` section
- Logic to handle legacy env var, config override and default cache dir
  selection is now in the `Config::try_from(RawConfig)` impl
- Deprecate old `TEALDEER_CACHE_DIR` env variable
- Update docs

Co-authored-by: Hans Gaiser <hansg91@gmail.com>
2022-10-01 12:13:39 +02:00
Olav de Haas
f4a94112f4
Add custom pages to list output (#285)
Fixes #205.
2022-09-24 21:27:35 +02:00
Evan Lloyd New-Schmidt
4a5410fd0b Add support for android platform
tldr added android-specific commands under a new 'android' platform
last year: <https://github.com/tldr-pages/tldr/issues/5462>
2022-06-02 12:36:20 -04:00
Danilo Bargen
77a6d48381 Pages download: Check return status 2022-01-09 21:14:30 +01:00
Danilo Bargen
71b6e037a7 When decompressing ZIP fails, propagate error
Do not unwrap. Instead, propagate the error with a anyhow context.
2022-01-09 21:14:30 +01:00
Danilo Bargen
fd307757d7 Port cache and output modules to anyhow results 2022-01-09 01:04:07 +01:00
Danilo Bargen
84277cc31e
Cache: Return error if HTTP client cannot be created (#247)
Apparently `Client::new` can panic (see #244), so let's return the error instead.
2022-01-08 22:01:36 +01:00
Danilo Bargen
ed3d1ea9af Always add empty line before concatenating patch file 2021-12-30 21:09:37 +01:00
Danilo Bargen
fb40974616 Cache: Add tests for PageLookupResult::reader
Co-authored-by: Dalton Maahs <dalton.maahs@yourbind.com>
2021-12-30 00:01:31 +01:00
Danilo Bargen
0ef31d1f17 Concatenate page and patch bytes before processing
This way a patch file does not need a well-formed header anymore.

Fixes #181.
2021-12-30 00:01:31 +01:00
Danilo Bargen
0fbc95cb71
Rename -o / --os to -p / --platform (#217)
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.
2021-12-05 13:28:58 +01:00
Danilo Bargen
9c90f8ba7a
Fix clippy lints added in 1.57 (#225) 2021-12-04 21:34:06 +01:00
Danilo Bargen
746d4dadda
Fix clippy warnings (#222)
- Silence warning about excessive bools
- Implement recommendation about unneeded Option in return type
2021-10-24 23:30:10 +02:00
Danilo Bargen
5ad7dcfa34 Argument parsing: Switch from docopt to clap 2021-10-17 21:12:08 +02:00
invakid404
62725fca5f When clearing cache, only delete pages, not entire cache dir
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
2021-10-16 20:09:32 +02:00
invakid404
006ec6f3c0 Switch to recommended tldr-pages archive URL
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
2021-10-16 20:09:32 +02:00
Danilo Bargen
7bd08e35d1 Refactor cache freshness checks
- 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>
2021-10-16 20:09:16 +02:00
Danilo Bargen
e84fce6f90
Use tree-style imports (#204) 2021-09-13 09:06:21 +02:00
Danny Mösch
1471b1d97b
Create cache directory path if it does not exist (#174)
Fixes #167
2021-09-12 20:28:22 +02:00
Marcin Puc
a4ac910e86 Add various small refactorings 2021-08-29 16:12:24 +02:00
Dalton
0fce79f8ed
Add unit tests for custom pages / patches (#183) 2021-04-23 20:06:44 +02:00
Danny Mösch
2a304b17f2
Fix clippy warnings (#173) 2021-04-18 19:27:25 +02:00
Dalton
07c715656f
Support custom pages and patches (#142)
Allow adding, overriding and extending custom pages.

Fixes #98.
2021-04-18 19:22:41 +02:00
Danny Mösch
7232bdd898
Allow SunOS override (#176)
Fixes #82.
2021-04-14 20:55:27 +02:00
Danilo Bargen
cb57ac1d5d Require Rust 1.41 (was 1.40)
This is required for Result::map_or_else.

Additionally, run clippy with 1.41 as well. Otherwise it reports
suggestions that are not compatible with 1.41.
2021-02-05 00:12:57 +01:00
Danilo Bargen
ca15279386 Show reason for choice of a certain cache/config dir 2021-02-04 23:53:14 +01:00
Danilo Bargen
978debe6ae Implement new --show-dirs command
The command prints out the different directories (config, cache, etc)
used by tealdeer.
2021-01-30 21:32:39 +01:00
Danilo Bargen
127124eded Optimize get_languages function
- Replace `Result` parameters with `Option`
- Replace `HashSet` for deduplication with linear search based approach
- Avoid intermediate allocations

This reduces the instruction count in release mode by almost 50%.
2021-01-29 12:05:01 +01:00
Niklas Mohrin
1db4b409bc Add support for multiple languages (#125)
The implementation follows the tldr-pages client spec:
https://github.com/tldr-pages/tldr/blob/master/CLIENT-SPECIFICATION.md#language

Fixes #96
2021-01-29 00:00:10 +01:00
Danilo Bargen
e507343f5d
CI: Run clippy with Rust 1.46 (#132) 2020-08-30 19:55:38 +02:00
Danilo Bargen
3597e344cb Apply rustfmt to codebase
Co-authored-by: Atul Bhosale <atul1bhosale@gmail.com>
Co-authored-by: Lovecraftian Horror <LovecraftianHorror@pm.me>
2020-08-30 18:39:29 +02:00
Danilo Bargen
04e61080d2 Upgrade reqwest
This reduces the dependency tree from 333 to 188 entries, mostly because
some reqwest features were disabled :)
2020-02-28 00:20:37 +01:00
Jesús Trinidad Díaz Ramírez
055758dba8
Fix clippy warnings (#101) 2020-02-06 15:43:00 +01:00
Danilo Bargen
7460cdac6d Remove unused import 2019-10-04 01:18:36 +02:00
Gabriel Martinez
495c3e97d9 Support colors on Windows using ansi_term
We try to enable ANSI color support on Windows using the new APIs.
If that succeeds, we print colors as usual. If it fails, we disable
styles completely.
2019-02-09 21:44:10 -08:00
Jason Liquorish
265ed66d7d Add Windows support 2019-02-05 09:32:13 -08:00
Danilo Bargen
9548f1dd1b
More clippy pedantism! (#70) 2018-12-07 12:25:25 +01:00
Danilo Bargen
f5e081ab68
Rust 2018 (#69) 2018-12-07 11:42:39 +01:00
Ivan Smirnov
f3cabddd0d Add (back) support for proxies (#68)
Fixes #65
2018-11-22 16:09:54 +01:00
Jan Christian Gruenhage
db2fe596ca Move from curl to reqwest
Fixes #60
2018-11-19 10:53:44 +01:00
equal-l2
ac9db25691 Run rustfmt 2018-10-21 14:49:01 +02:00