Skip to content
Open
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
8 changes: 7 additions & 1 deletion tests/test_help_docs.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from __future__ import annotations

import importlib
from types import SimpleNamespace

from trushell.commands.core import run_help


def test_run_help_prints_docstring_for_known_command(monkeypatch, capsys):
def _fake_import_module(path: str):
module = importlib.import_module(path.replace("/", ".").removesuffix(".py"))
return module

fake_kernel = SimpleNamespace(
registry={
"settings": {
"path": "trushell/commands/settings.py",
"function": "run_settings",
}
}
},
_import_module=_fake_import_module,
)

monkeypatch.setattr("trushell.core.trukernel.get_kernel", lambda: fake_kernel)
Expand Down
10 changes: 5 additions & 5 deletions trushell/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

def app_with_lower() -> None:
"""Entry point that normalizes the first argument to lowercase for case-insensitive invocation."""
if len(sys.argv) > 1:
# Create a local copy to avoid mutating the global sys.argv
argv_copy = sys.argv.copy()
if argv_copy[1].lower() not in {"--help", "-h", "version"}:
raw = " ".join(argv_copy[1:])
# Create a local copy to avoid mutating the global sys.argv
argv = sys.argv.copy()
if len(argv) > 1:
if argv[1].lower() not in {"--help", "-h", "version"}:
raw = " ".join(argv[1:]).lower()
get_kernel().execute_command(raw)
return

Expand Down
Loading