Skip to content

Commit 6779723

Browse files
authored
Merge branch 'main' into main
2 parents 6a3bbfb + ff2b92b commit 6779723

File tree

15 files changed

+492
-145
lines changed

15 files changed

+492
-145
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ updates:
33
- package-ecosystem: "github-actions"
44
directory: "/"
55
schedule:
6-
interval: "monthly"
6+
interval: "weekly"

.github/workflows/publish.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
1+
# This workflow will upload a Python Package using Trusted Publishers automatically when a release is created
22
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
# and https://docs.pypi.org/trusted-publishers/using-a-publisher/.
34

45
name: Upload Python Package
56

@@ -8,14 +9,22 @@ on:
89
types: [created]
910

1011
jobs:
11-
deploy:
12-
12+
pypi-publish:
1313
runs-on: ubuntu-latest
14+
15+
environment:
16+
name: pypi
17+
url: https://pypi.org/project/tldr/
18+
19+
permissions:
20+
contents: read
21+
id-token: write # Required for accessing OpenID Connect (OIDC) token for PyPI trusted publisher
22+
1423
steps:
15-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1625

1726
- name: Set up Python
18-
uses: actions/setup-python@v5
27+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
1928
with:
2029
python-version: '3.8'
2130

@@ -56,7 +65,4 @@ jobs:
5665
.
5766
5867
- name: Publish package
59-
uses: pypa/gh-action-pypi-publish@release/v1
60-
with:
61-
user: __token__
62-
password: ${{ secrets.PYPI_PASSWORD }}
68+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

.github/workflows/test.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ on: ['push', 'pull_request']
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
runs-on: ${{ matrix.os }}
88

99
strategy:
1010
matrix:
11+
os: ['ubuntu-latest', 'ubuntu-24.04-arm']
1112
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9', 'pypy3.10']
1213

1314
steps:
14-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1516

1617
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v5
18+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
1819
with:
1920
python-version: ${{ matrix.python-version }}
2021

@@ -25,15 +26,15 @@ jobs:
2526
2627
- name: Install sphinx dependencies
2728
run: >-
28-
python -m
29+
python3 -m
2930
pip install
3031
sphinx
3132
sphinx-argparse
3233
--user
3334
3435
- name: Install tldr dependencies
3536
run: >-
36-
python -m
37+
python3 -m
3738
pip install
3839
-r
3940
requirements.txt
@@ -47,23 +48,30 @@ jobs:
4748
run: python3 -m flake8
4849

4950
- name: Run test suite
50-
run: python3 setup.py pytest
51+
run: python3 -m pytest tests/
5152

5253
- name: Test tldr cli
5354
run: |
5455
python3 -m pip install .
5556
tldr --version
5657
5758
build-snap:
58-
runs-on: ubuntu-latest
59+
runs-on: ${{ matrix.os }}
60+
needs: ['build']
61+
62+
strategy:
63+
matrix:
64+
os: ['ubuntu-latest', 'ubuntu-24.04-arm']
5965

6066
steps:
6167
- uses: actions/checkout@v4
62-
- uses: snapcore/action-build@v1
68+
69+
- uses: canonical/action-build@3bdaa03e1ba6bf59a65f84a751d943d549a54e79 # v1.3.0
6370
id: snapcraft-build
6471
with:
6572
snapcraft-args: "-v"
66-
- uses: actions/upload-artifact@v4
73+
74+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
6775
with:
6876
name: ${{ steps.snapcraft-build.outputs.snap }}
6977
path: ${{ steps.snapcraft-build.outputs.snap }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ instance/
7070

7171
# Sphinx documentation
7272
docs/_build/
73-
docs/man
73+
docs/man/.doctrees
7474

7575
# PyBuilder
7676
.pybuilder/

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Changelog
22

3+
## 3.3.0 (06/29/2024)
4+
5+
## Breaking
6+
7+
* Drop support for EOL versions Python 3.6 and Python 3.7.
8+
9+
### Bugfixes
10+
11+
* Return `str` instead of `list` when executing `tldr -l` (thanks [@uunnxx](https://github.com/uunnxx))
12+
* Use pathlib instead of os.path (thanks [@vitorhcl](https://github.com/vitorhcl))
13+
* Respect language settings when geting a list of commands (thanks [@frenzymadness](https://github.com/frenzymadness))
14+
* Fix `--search` option (thanks [@CleanMachine1](https://github.com/CleanMachine1))
15+
16+
### Features
17+
18+
* Add support for BSD platform directories (thanks [@vitorhcl](https://github.com/vitorhcl))
19+
* Add `--update` long option (thanks [@owenvoke](https://github.com/owenvoke))
20+
* Add support for fetching individual translation archives for cache (thanks [@SaurabhDRao](https://github.com/SaurabhDRao))
21+
* Add support to show message for other versions of the same page in other platforms (thanks [@Jaimepas77](https://github.com/Jaimepas77))
22+
* Update `DOWNLOAD_CACHE_LOCATION` to use GitHub Releases (thanks [@vitorhcl](https://github.com/vitorhcl))
23+
* Add `macos` alias for `osx` directory and update `--platform` option (thanks [@patricedenis](https://github.com/patricedenis))
24+
* Add support for escaping placeholders for special pages (thanks [@kbdharun](https://github.com/kbdharun))
25+
* Add support for Python 3.11 and Python 3.12 (thanks [@kbdharun](https://github.com/kbdharun))
26+
* Add support for [Client Specification v2.2](https://github.com/tldr-pages/tldr/releases/tag/v2.2)
27+
328
## 3.2.0 (05/09/2023)
429

530
### Bugfixes

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Felix Yan
3+
Copyright (c) 2014 Felix Yan and 2014-present tldr-pages contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
[![PyPI Release](https://img.shields.io/pypi/v/tldr.svg)](https://pypi.python.org/pypi/tldr)
44
[![Build](https://github.com/tldr-pages/tldr-python-client/workflows/Test/badge.svg?branch=main)](https://github.com/tldr-pages/tldr-python-client/actions?query=branch%3Amain)
5+
[![Snap Release](https://snapcraft.io/tldr/badge.svg)](https://snapcraft.io/tldr)
56

67
Python command-line client for [tldr pages](https://github.com/tldr-pages/tldr).
78

8-
![tldr pages example](https://raw.github.com/tldr-pages/tldr/main/images/tldr-dark.png)
9+
![Tldr Python client displaying the tar page](https://raw.github.com/tldr-pages/tldr-python-client/main/images/tldr-dark.png)
910

1011
## Installation
1112

12-
[![Packaging status](https://repology.org/badge/vertical-allrepos/tldr-python-client.svg)](https://repology.org/project/python-tldr-client/versions)
13+
<details open>
14+
<summary>Check Repology Packaging Status!</summary>
15+
<a href="https://repology.org/project/tldr-python-client/versions">
16+
<img src="https://repology.org/badge/vertical-allrepos/tldr-python-client.svg" alt="Packaging status">
17+
</a>
18+
</details>
1319

1420
### from PyPI
1521

@@ -37,28 +43,32 @@ sudo snap install tldr
3743

3844
## Usage
3945

40-
```
41-
usage: tldr [-u] [-p PLATFORM] [-s SOURCE] [-c] [-r] [-L LANGUAGE] command
46+
```txt
47+
usage: tldr command [options]
4248
4349
Python command line client for tldr
4450
4551
positional arguments:
4652
command command to lookup
4753
48-
optional arguments:
54+
options:
4955
-h, --help show this help message and exit
5056
-v, --version show program's version number and exit
51-
-u, --update_cache Update the local cache of pages and exit
57+
--search "KEYWORDS" Search for a specific command from a query
58+
-u, --update, --update_cache
59+
Update the local cache of pages and exit
5260
-p PLATFORM, --platform PLATFORM
53-
Override the operating system [linux, osx, sunos,
54-
windows, common]
61+
Override the operating system [android, freebsd, linux, netbsd, openbsd, osx, sunos, windows, common]
62+
-l, --list List all available commands for operating system
5563
-s SOURCE, --source SOURCE
5664
Override the default page source
5765
-c, --color Override color stripping
5866
-r, --render Render local markdown files
59-
-l, --list List all available commands for operating system
6067
-L LANGUAGE, --language LANGUAGE
6168
Override the default language
69+
-m, --markdown Just print the plain page file.
70+
--print-completion {bash,zsh,tcsh}
71+
print shell completion script
6272
```
6373

6474
## Configuration
@@ -75,24 +85,26 @@ export TLDR_LANGUAGE="es"
7585
export TLDR_CACHE_ENABLED=1
7686
export TLDR_CACHE_MAX_AGE=720
7787
export TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/main/pages"
78-
export TLDR_DOWNLOAD_CACHE_LOCATION="https://tldr-pages.github.io/assets/tldr.zip"
88+
export TLDR_DOWNLOAD_CACHE_LOCATION="https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip"
89+
export TLDR_OPTIONS=short
7990
```
8091

8192
### Cache
8293

8394
Cache is downloaded from `TLDR_DOWNLOAD_CACHE_LOCATION` (defaults to the one described in [the client specification](https://github.com/tldr-pages/tldr/blob/main/CLIENT-SPECIFICATION.md#caching)), unzipped and extracted into the [local cache directory](#cache-location). Pages are loaded directly from `TLDR_PAGES_SOURCE_LOCATION` if `tldr <command>` is used.
8495

85-
* `TLDR_CACHE_ENABLED` (default is `1`):
86-
* If set to `1`, the client will first try to load from cache, and fall back to fetching from the internet if the cache doesn't exist or is too old.
87-
* If set to `0`, the client will fetch from the internet, and fall back to the cache if the page cannot be fetched from the internet.
88-
* `TLDR_CACHE_MAX_AGE` (default is `168` hours, which is equivalent to a week): maximum age of the cache in hours to be considered as valid when `TLDR_CACHE_ENABLED` is set to `1`.
96+
- `TLDR_CACHE_ENABLED` (default is `1`):
97+
- If set to `1`, the client will first try to load from cache, and fall back to fetching from the internet if the cache doesn't exist or is too old.
98+
- If set to `0`, the client will fetch from the internet, and fall back to the cache if the page cannot be fetched from the internet.
99+
- `TLDR_CACHE_MAX_AGE` (default is `168` hours, which is equivalent to a week): maximum age of the cache in hours to be considered as valid when `TLDR_CACHE_ENABLED` is set to `1`.
89100

90101
#### Cache location
91102

92103
In order of precedence:
93-
* `$XDG_CACHE_HOME/tldr`
94-
* `$HOME/.cache/tldr`
95-
* `~/.cache/tldr`
104+
105+
- `$XDG_CACHE_HOME/tldr`
106+
- `$HOME/.cache/tldr`
107+
- `~/.cache/tldr`
96108

97109
If you are experiencing issues with *tldr*, consider deleting the cache files before trying other measures.
98110

@@ -121,7 +133,7 @@ an autocomplete for `tldr` for `fish`.
121133

122134
For networks that sit behind a proxy, it may be necessary to disable SSL verification for the client to function. Setting the following:
123135

124-
* `TLDR_ALLOW_INSECURE=1`
136+
- `TLDR_ALLOW_INSECURE=1`
125137

126138
will disable SSL certificate inspection. This __should be avoided__ unless absolutely necessary.
127139

@@ -132,30 +144,34 @@ It is possible to use a different certificate store/bundle by setting:
132144
### Colors
133145

134146
Values of the `TLDR_COLOR_x` variables may consist of three parts:
135-
* Font color: `blue, green, yellow, cyan, magenta, white, grey, red`
136-
* Background color: `on_blue, on_cyan, on_magenta, on_white, on_grey, on_yellow, on_red, on_green`
137-
* Additional effects, which depends on platform: `reverse, blink, dark, concealed, underline, bold`
147+
148+
- Font color: `blue, green, yellow, cyan, magenta, white, grey, red`
149+
- Background color: `on_blue, on_cyan, on_magenta, on_white, on_grey, on_yellow, on_red, on_green`
150+
- Additional effects, which depend on the platform: `reverse, blink, dark, concealed, underline, bold`
138151

139152
You may specify as many additional effects as you want, while only one of font and background color.
140153

141-
Any of the values of above may be omitted. For example, you can do similar things as the following:
142-
* `TLDR_COLOR_NAME=""` use default system font color with default background color without any effects
143-
* `TLDR_COLOR_DESCRIPTION="white"` for white text on default system background color without any effects
144-
* `TLDR_COLOR_NAME="cyan dark"` for dark cyan text on default system background color
145-
* `TLDR_COLOR_NAME="on_red"` for default system font color on red background color
146-
* `TLDR_COLOR_PARAMETER="red on_yellow underline"` for underlined red text on yellow background
147-
* `TLDR_COLOR_NAME="bold underline"` for default system font and background colors with underline and bolded effects
154+
Any of the values above may be omitted. For example, you can do similar things as the following:
155+
156+
- `TLDR_COLOR_NAME=""` use default system font color with default background color without any effects
157+
- `TLDR_COLOR_DESCRIPTION="white"` for white text on default system background color without any effects
158+
- `TLDR_COLOR_NAME="cyan dark"` for dark cyan text on default system background color
159+
- `TLDR_COLOR_NAME="on_red"` for default system font color on the red background color
160+
- `TLDR_COLOR_PARAMETER="red on_yellow underline"` for underlined red text on yellow background
161+
- `TLDR_COLOR_NAME="bold underline"` for default system font and background colors with underline and bolded effects
148162

149163
### Language
150164

151-
The language that tldr will use is dependent on a number of factors. If you specify a language via the
165+
The language that tldr will use is dependent on several factors. If you specify a language via the
152166
`--language` flag, tldr will attempt to use that language and only that language. Otherwise, it will
153167
try to use the language specified by `TLDR_LANGUAGE`. If it is not set, or the page does not exist in that language,
154168
then tldr will use the
155169
language set using `LANGUAGE` and `LANG` (ignoring the values `C` and `POSIX`).
156-
If neither are set, then tldr will always attempt to get the `en` page. Finally, if `LANG` is set, it uses `LANGUAGE`, if set,
157-
first as the priority list to try languages in, followed by `LANG` if not included in `LANGUAGE`
158-
and `en` as fallback (assuming it does not already appear somewhere in `LANGUAGE` or `LANG`).
170+
171+
If neither is set, then tldr will always attempt to get the `en` page. Finally, if `LANG` is set, it uses `LANGUAGE`, if set,
172+
first, as the priority list to try languages in, followed by `LANG` if not included in `LANGUAGE`
173+
and `en` as a fallback (assuming it does not already appear somewhere in `LANGUAGE` or `LANG`).
174+
159175
All language values should be set to a value that follows [RFC 1766](https://tools.ietf.org/html/rfc1766.html),
160176
with the special exceptions of `C` and `POSIX` which are ignored.
161177

@@ -164,8 +180,12 @@ with the special exceptions of `C` and `POSIX` which are ignored.
164180
If you wish to use your own instance of the tldr pages instead of the default repository, you
165181
can either use the `--source` flag when using tldr or by specifying the following environment variables:
166182

167-
* `TLDR_PAGES_SOURCE_LOCATION` to control where to get individual pages from
168-
* defaults to `https://raw.githubusercontent.com/tldr-pages/tldr/main/pages`
169-
* it can also point to local directory using `file:///path/to/directory`
170-
* `TLDR_DOWNLOAD_CACHE_LOCATION` to control where to pull a zip of all pages from
171-
* defaults to `https://tldr-pages.github.io/assets/tldr.zip`
183+
- `TLDR_PAGES_SOURCE_LOCATION` to control where to get individual pages from.
184+
- defaults to `https://raw.githubusercontent.com/tldr-pages/tldr/main/pages`.
185+
- it can also point to a local directory using `file:///path/to/directory`.
186+
- `TLDR_DOWNLOAD_CACHE_LOCATION` to control where to pull a zip of all pages from.
187+
- defaults to `https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip`.
188+
189+
### Command options
190+
191+
Pages might contain `{{[*|*]}}` patterns to let the client decide whether to show shortform or longform versions of options. This can be configured with `TLDR_OPTIONS`, which accepts values `short`, `long` and `both`

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
# -- Project information -----------------------------------------------------
1818

1919
project = 'tldr'
20-
copyright = '2014, Felix Yan'
21-
author = 'Felix Yan'
20+
copyright = '2014, Felix Yan and 2014-present, tldr-pages contributors'
21+
author = 'Felix Yan and tldr-pages contributors'
2222
from tldr import __version__ # noqa: E402
2323
release = __version__
2424

0 commit comments

Comments
 (0)