Skip to content

Commit c987ac8

Browse files
authored
tldr: fix tab completion (#294)
1 parent f914e31 commit c987ac8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/test_tldr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ def test_get_commands(monkeypatch, tmp_path):
147147
result = tldr.get_commands(platforms=["linux"])
148148

149149
assert isinstance(result, list)
150-
assert "lspci (en)" in result
150+
assert "lspci" in result
151151

152152
cache_zh = tmp_path / ".cache" / "tldr" / "pages.zh" / "linux"
153153
Path.mkdir(cache_zh, parents=True)
154154
Path.touch(cache_zh / "lspci.md")
155155

156156
result = tldr.get_commands(platforms=["linux"], language=["zh_CN"])
157157

158-
assert "lspci (zh)" in result
158+
assert "lspci" in result

tldr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def get_commands(platforms: Optional[List[str]] = None,
401401
path = get_cache_dir() / pages_dir / platform
402402
if not path.exists():
403403
continue
404-
commands += [f"{file.stem} ({language})"
404+
commands += [f"{file.stem}"
405405
for file in path.iterdir()
406406
if file.suffix == '.md']
407407
return commands
@@ -654,10 +654,10 @@ def create_parser() -> ArgumentParser:
654654

655655
shtab.add_argument_to(parser, preamble={
656656
'bash': r'''shtab_tldr_cmd_list(){{
657-
compgen -W "$("{py}" -m tldr --list | sed 's/[^[:alnum:]_]/ /g')" -- "$1"
657+
compgen -W "$("{py}" -m tldr --list)" -- "$1"
658658
}}'''.format(py=sys.executable),
659659
'zsh': r'''shtab_tldr_cmd_list(){{
660-
_describe 'command' "($("{py}" -m tldr --list | sed 's/[^[:alnum:]_]/ /g'))"
660+
_describe 'command' "($("{py}" -m tldr --list))"
661661
}}'''.format(py=sys.executable)
662662
})
663663

0 commit comments

Comments
 (0)