Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_tldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ 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)
Path.touch(cache_zh / "lspci.md")

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

assert "lspci (zh)" in result
assert "lspci" in result
6 changes: 3 additions & 3 deletions tldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
})

Expand Down
Loading