Commit graph

56 commits

Author SHA1 Message Date
Danilo Bargen
7338933de5 Add integration test for cache_dir 2022-10-01 12:13:40 +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
Kian-Meng Ang
97b4395e25
Fix typos (#277) 2022-06-20 12:35:17 +00:00
Danilo Bargen
5a1a21b8ab
Add note about auto-updates when cache is missing (#254) 2022-02-06 22:53:48 +01:00
Danilo Bargen
fd307757d7 Port cache and output modules to anyhow results 2022-01-09 01:04:07 +01:00
Danilo Bargen
00ec281b9b Include custom pages directory in --show-paths command 2021-12-20 00:25:48 +01:00
Danilo Bargen
1a3624d011
Introduce command_or_file arg group (#230)
This allows to say "this command line parameter requires either a
command or a raw file".

Fixes #219.
2021-12-05 20:45:35 +01:00
Danilo Bargen
023a9d2079
Lowercase page names before lookup (#227) 2021-12-05 14:31:03 +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
8833b6b401 Rename -m / --markdown to -r / --raw
That flag name is clearer: We output raw page data without processing.
2021-10-17 21:12:08 +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
Danilo Bargen
07dc5c6bf4 Upgrade predicates and assert_cmd: 1 → 2 2021-09-12 21:12:00 +02:00
Danilo Bargen
a811788b31
Merge pull request #189 from niklasmohrin/simplify_highlight_commands
Refactor formatting code
2021-09-12 20:31:45 +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
Niklas Mohrin
b216a63c64
Add integration test for non-ascii page rendering
Although this did not fail on old master, it is still an important case
to test. Actually, this test doesn't even break when introducing some
errors that fail i18n unit tests, unless the command name itself is
non-ascii.
2021-09-08 14:44:10 +02:00
Marcin Puc
a4ac910e86 Add various small refactorings 2021-08-29 16:12:24 +02:00
Danny Mösch
b6342633cd
Use which instead of tar as reference tldr page in tests (#192)
The page for `tar` changes pretty frequently. `which` was last updated in 2018 and is a rather simple command overall. So it is less likely that the reference in the repository has to be updated as often as the one for `tar`.
2021-05-13 14:12:11 +02:00
Dalton
4d4c7b6a5d
Fix clippy warnings (#188)
* Fix clippy warnings
* Update toolchain for CI workflows fmt and clippy
2021-05-11 13:28:26 +02:00
Dalton
388deac079
Send all progress logging messages to stderr (#171)
- 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
2021-05-10 09:17:13 +02:00
Dalton
0fce79f8ed
Add unit tests for custom pages / patches (#183) 2021-04-23 20:06:44 +02:00
Danny Mösch
7232bdd898
Allow SunOS override (#176)
Fixes #82.
2021-04-14 20:55:27 +02:00
Danny Mösch
49f151a605
Remove 'extern crate' declarations (#175)
Cargo.toml specifies Rust Edition 2018 which does not require 'extern crate' anymore.
2021-04-10 21:33:48 +02: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
Danny Mösch
1d529de260
Consider only standalone command names for styling (#157) 2021-01-29 21:22:52 +01:00
Bruno A. Muciño
d2b5614f1a Replace deprecated tempdir crate with tempfile crate (#139)
Fixes #134.
2020-09-04 11:59:10 +02:00
Lovecraftian Horror
dc6af5ad6c Add integration tests for the auto/never color options 2020-08-31 00:08:54 +02:00
Lovecraftian Horror
bc04e1ac00 Disable styling for --color auto if the output is being piped 2020-08-31 00:08:54 +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
0b277c7515
Add test for pager warnings on Windows (#122) 2020-07-18 01:06:58 +02:00
Ilaï Deutel
a59182b6cc Use filetime instead of utime to set modification times in tests 2020-05-31 17:12:57 -07:00
Ilaï Deutel
ed1ba6beed Implement automatic cache updates 2020-05-31 17:12:57 -07:00
Danilo Bargen
06537c7218
Tests: Allow dead code for feature selection (#118)
These methods might be useful in the future, so I don't want to remove them even if they're unused. The warnings clutter diffs in CI though.
2020-05-08 22:40:34 +02:00
michaeldel
a45c19647f
Move cache age warning to stderr (#114)
Fixes #113
2020-04-16 21:42:02 +02:00
michaeldel
5dd9457cf4
Make list option comply with official spec (#112)
Separate page list with newlines, not with commas.

From the official spec:

> Additional decoration MAY be printed if the standard output is a TTY.
> If not, then the output MUST not contain any additional decorations.
> For example a page list MUST be formatted with 1 page name per line
> (to enable easy manipulation using standard CLI tools such as grep etc.).
2020-04-16 11:56:14 +02:00
Danilo Bargen
23d7301b53
Merge pull request #95 from Plommonsorbet/render_as_markdown_option
Add -m / --markdown option for raw rendering
2020-01-22 23:06:03 +01:00
Isak Johansson
6719acb4f2 Add -m / --markdown option for raw rendering
New option to render as markdown, not with ANSI escape codes.
This is useful for when you want to open it up in a pager which doesn't
support ANSI escape codes by default. In my use case it allows me to
open it inside vim without having to use an addon to convert ANSI escape
codes to colours.
2020-01-22 22:54:11 +01:00
Hugo Locurcio
0d00e60af0 Tweak the outdated cache warning message (#97)
This makes it display in yellow (instead of red) as it's
more of a *warning* message than an *error* message.
2020-01-07 09:16:40 +01:00
jdvr
0879116a45 Add pager support 2019-03-11 10:52:12 +01:00
Jason Liquorish
265ed66d7d Add Windows support 2019-02-05 09:32:13 -08:00
Jonathan Dahan
91c7a412f0 Add support for spaces in commands (#75)
For example "git commit".

Fixes #74.
2019-01-14 09:28:48 +01:00
Danilo Bargen
240e36a389
Switch from assert_cli to assert_cmd (#66) 2018-11-21 22:26:14 +01:00
Danilo Bargen
f1988a645b Fix loading of configfile
- Don't require config file to exist for `--config-path` flag
- Make `--config-path` option pass-through
- Add a test for the `--config-path` flag
2018-10-22 18:03:49 +02:00
Danilo Bargen
e2d61e3ef2 Change wording of outdated cache message 2018-10-22 17:48:20 +02:00
equal-l2
ac9db25691 Run rustfmt 2018-10-21 14:49:01 +02:00
Jonathan Dahan
8784b55ba8 Add --quiet flag to surpress non-error output (#48) 2018-09-18 21:12:21 +02:00
Danilo Bargen
f21e885d85 Syntax config path -> config path 2018-09-16 00:41:58 +02:00