From ac99ab81975194264259bc1060190452f61afc88 Mon Sep 17 00:00:00 2001 From: Antti Savolainen Date: Wed, 13 Aug 2025 09:05:36 +0300 Subject: [PATCH 1/4] Fix tab completion --- tldr.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tldr.py b/tldr.py index 161e960..bd81398 100755 --- a/tldr.py +++ b/tldr.py @@ -401,7 +401,10 @@ def get_commands(platforms: Optional[List[str]] = None, path = get_cache_dir() / pages_dir / platform if not path.exists(): continue - commands += [f"{file.stem} ({language})" + languagestring = "" + if language != 'en': + languagestring = f" ({language})" + commands += [f"{file.stem}{languagestring}" for file in path.iterdir() if file.suffix == '.md'] return commands @@ -654,10 +657,10 @@ def create_parser() -> ArgumentParser: shtab.add_argument_to(parser, preamble={ 'bash': r'''shtab_tldr_cmd_list(){{ - compgen -W "$("{py}" -m tldr --list | sed 's/[^[:alnum:]_]/ /g')" -- "$1" + compgen -W "$("{py}" -m tldr --list)" -- "$1" }}'''.format(py=sys.executable), 'zsh': r'''shtab_tldr_cmd_list(){{ - _describe 'command' "($("{py}" -m tldr --list | sed 's/[^[:alnum:]_]/ /g'))" + _describe 'command' "($("{py}" -m tldr --list))" }}'''.format(py=sys.executable) }) From 8f8a6fe24b1d15a83687916e1de388792f0d42e3 Mon Sep 17 00:00:00 2001 From: Antti Savolainen Date: Wed, 13 Aug 2025 09:25:30 +0300 Subject: [PATCH 2/4] remove language marker completely --- tldr.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tldr.py b/tldr.py index bd81398..331ff8c 100755 --- a/tldr.py +++ b/tldr.py @@ -402,9 +402,7 @@ def get_commands(platforms: Optional[List[str]] = None, if not path.exists(): continue languagestring = "" - if language != 'en': - languagestring = f" ({language})" - commands += [f"{file.stem}{languagestring}" + commands += [f"{file.stem}" for file in path.iterdir() if file.suffix == '.md'] return commands From f1fbfb8e0f69b7c74f6b44ed93c6f9a4f1105ff5 Mon Sep 17 00:00:00 2001 From: Antti Savolainen Date: Wed, 13 Aug 2025 09:26:22 +0300 Subject: [PATCH 3/4] forgot --- tldr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tldr.py b/tldr.py index 331ff8c..02456a3 100755 --- a/tldr.py +++ b/tldr.py @@ -401,7 +401,6 @@ def get_commands(platforms: Optional[List[str]] = None, path = get_cache_dir() / pages_dir / platform if not path.exists(): continue - languagestring = "" commands += [f"{file.stem}" for file in path.iterdir() if file.suffix == '.md'] From be1590a7f768bd8100f135d11b3f03b4975f99da Mon Sep 17 00:00:00 2001 From: Managor <42655600+Managor@users.noreply.github.com> Date: Wed, 13 Aug 2025 09:35:28 +0300 Subject: [PATCH 4/4] Update test_tldr.py --- tests/test_tldr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_tldr.py b/tests/test_tldr.py index 9fd713a..b48f31f 100644 --- a/tests/test_tldr.py +++ b/tests/test_tldr.py @@ -147,7 +147,7 @@ def test_get_commands(monkeypatch, tmp_path): result = tldr.get_commands(platforms=["linux"]) assert isinstance(result, list) - assert "lspci (en)" in result + assert "lspci" in result cache_zh = tmp_path / ".cache" / "tldr" / "pages.zh" / "linux" Path.mkdir(cache_zh, parents=True) @@ -155,4 +155,4 @@ def test_get_commands(monkeypatch, tmp_path): result = tldr.get_commands(platforms=["linux"], language=["zh_CN"]) - assert "lspci (zh)" in result + assert "lspci" in result