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 diff --git a/tldr.py b/tldr.py index 161e960..02456a3 100755 --- a/tldr.py +++ b/tldr.py @@ -401,7 +401,7 @@ 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})" + commands += [f"{file.stem}" for file in path.iterdir() if file.suffix == '.md'] return commands @@ -654,10 +654,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) })