Skip to content

Commit cf58a25

Browse files
authored
Merge branch 'main' into feat/-clear-cache-option
2 parents 9287bfa + 1a565b0 commit cf58a25

File tree

16 files changed

+324
-67
lines changed

16 files changed

+324
-67
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: 5 additions & 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/
@@ -114,6 +114,10 @@ ENV/
114114
env.bak/
115115
venv.bak/
116116

117+
# direnv
118+
.envrc
119+
.direnv/
120+
117121
# Spyder project settings
118122
.spyderproject
119123
.spyproject

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: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
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

@@ -42,7 +43,7 @@ sudo snap install tldr
4243

4344
## Usage
4445

45-
```
46+
```txt
4647
usage: tldr command [options]
4748
4849
Python command line client for tldr
@@ -59,7 +60,7 @@ options:
5960
-k, --clear-cache
6061
Delete the local cache of pages and exit
6162
-p PLATFORM, --platform PLATFORM
62-
Override the operating system [linux, osx, sunos, windows, common]
63+
Override the operating system [android, freebsd, linux, netbsd, openbsd, osx, sunos, windows, common]
6364
-l, --list List all available commands for operating system
6465
-s SOURCE, --source SOURCE
6566
Override the default page source
@@ -86,21 +87,23 @@ export TLDR_LANGUAGE="es"
8687
export TLDR_CACHE_ENABLED=1
8788
export TLDR_CACHE_MAX_AGE=720
8889
export TLDR_PAGES_SOURCE_LOCATION="https://raw.githubusercontent.com/tldr-pages/tldr/main/pages"
89-
export TLDR_DOWNLOAD_CACHE_LOCATION="https://tldr-pages.github.io/assets/tldr.zip"
90+
export TLDR_DOWNLOAD_CACHE_LOCATION="https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip"
91+
export TLDR_OPTIONS=short
9092
```
9193

9294
### Cache
9395

9496
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.
9597

9698
- `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+
- 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.
100+
- 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.
99101
- `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`.
100102

101103
#### Cache location
102104

103105
In order of precedence:
106+
104107
- `$XDG_CACHE_HOME/tldr`
105108
- `$HOME/.cache/tldr`
106109
- `~/.cache/tldr`
@@ -135,10 +138,14 @@ an autocomplete for `tldr` for `fish`.
135138

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

138-
- `TLDR_ALLOW_INSECURE=1`
141+
- `TLDR_ALLOW_INSECURE=1`
139142

140143
will disable SSL certificate inspection. This __should be avoided__ unless absolutely necessary.
141144

145+
Alternatively, It is possible to use a different certificate store/bundle by setting:
146+
147+
* `TLDR_CERT=/path/to/certificates.crt`
148+
142149
### Colors
143150

144151
Values of the `TLDR_COLOR_x` variables may consist of three parts:
@@ -183,3 +190,7 @@ can either use the `--source` flag when using tldr or by specifying the followin
183190
- it can also point to a local directory using `file:///path/to/directory`.
184191
- `TLDR_DOWNLOAD_CACHE_LOCATION` to control where to pull a zip of all pages from.
185192
- defaults to `https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip`.
193+
194+
### Command options
195+
196+
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

docs/man/tldr.1

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.\" Man page generated from reStructuredText.
2+
.
3+
.
4+
.nr rst2man-indent-level 0
5+
.
6+
.de1 rstReportMargin
7+
\\$1 \\n[an-margin]
8+
level \\n[rst2man-indent-level]
9+
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
10+
-
11+
\\n[rst2man-indent0]
12+
\\n[rst2man-indent1]
13+
\\n[rst2man-indent2]
14+
..
15+
.de1 INDENT
16+
.\" .rstReportMargin pre:
17+
. RS \\$1
18+
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
19+
. nr rst2man-indent-level +1
20+
.\" .rstReportMargin post:
21+
..
22+
.de UNINDENT
23+
. RE
24+
.\" indent \\n[an-margin]
25+
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
26+
.nr rst2man-indent-level -1
27+
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
28+
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
29+
..
30+
.TH "TLDR" "1" "Jun 29, 2024" "" "tldr"
31+
.SH NAME
32+
tldr \- tldr 3.3.0
33+
.sp
34+
Python command line client for tldr
35+
36+
.INDENT 0.0
37+
.INDENT 3.5
38+
.sp
39+
.EX
40+
usage: tldr command [options]
41+
.EE
42+
.UNINDENT
43+
.UNINDENT
44+
.SH POSITIONAL ARGUMENTS
45+
.INDENT 0.0
46+
.TP
47+
.B command
48+
command to lookup
49+
.UNINDENT
50+
.SH NAMED ARGUMENTS
51+
.INDENT 0.0
52+
.TP
53+
.B \-v, \-\-version
54+
show program\(aqs version number and exit
55+
.TP
56+
.B \-\-search
57+
Search for a specific command from a query
58+
.TP
59+
.B \-u, \-\-update, \-\-update_cache
60+
Update the local cache of pages and exit
61+
.sp
62+
Default: False
63+
.TP
64+
.B \-p, \-\-platform
65+
Possible choices: android, freebsd, linux, netbsd, openbsd, osx, sunos, windows, common
66+
.sp
67+
Override the operating system [android, freebsd, linux, netbsd, openbsd, osx, sunos, windows, common]
68+
.TP
69+
.B \-l, \-\-list
70+
List all available commands for operating system
71+
.sp
72+
Default: False
73+
.TP
74+
.B \-s, \-\-source
75+
Override the default page source
76+
.sp
77+
Default: \(dq\X'tty: link https://raw.githubusercontent.com/tldr-pages/tldr/main/pages'\fI\%https://raw.githubusercontent.com/tldr\-pages/tldr/main/pages\fP\X'tty: link'\(dq
78+
.TP
79+
.B \-c, \-\-color
80+
Override color stripping
81+
.TP
82+
.B \-r, \-\-render
83+
Render local markdown files
84+
.sp
85+
Default: False
86+
.TP
87+
.B \-L, \-\-language
88+
Override the default language
89+
.TP
90+
.B \-m, \-\-markdown
91+
Just print the plain page file.
92+
.sp
93+
Default: False
94+
.TP
95+
.B \-\-print\-completion
96+
Possible choices: bash, zsh, tcsh
97+
.sp
98+
print shell completion script
99+
.UNINDENT
100+
.SH AUTHOR
101+
Felix Yan and tldr-pages contributors
102+
.SH COPYRIGHT
103+
2014, Felix Yan and 2014-present, tldr-pages contributors
104+
.\" Generated by docutils manpage writer.
105+
.

images/tldr-dark.png

83.1 KB
Loading

0 commit comments

Comments
 (0)