diff --git a/tests/test_help_docs.py b/tests/test_help_docs.py index 8eb08dd..99e9b03 100644 --- a/tests/test_help_docs.py +++ b/tests/test_help_docs.py @@ -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) diff --git a/trushell/cli.py b/trushell/cli.py index ff10ff7..ecf12a4 100644 --- a/trushell/cli.py +++ b/trushell/cli.py @@ -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