diff --git a/tests/test_help_docs.py b/tests/test_help_docs.py index 879d198..99e9b03 100644 --- a/tests/test_help_docs.py +++ b/tests/test_help_docs.py @@ -1,29 +1,26 @@ 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, ) - # Provide a minimal module object with the expected function and - # docstring so `run_help()` can import and print the docstring. - def run_settings(): - """Launch the TruShell settings TUI.""" - return None - - fake_module = SimpleNamespace(run_settings=run_settings) - fake_kernel._import_module = lambda path: fake_module - monkeypatch.setattr("trushell.core.trukernel.get_kernel", lambda: fake_kernel) run_help("settings") diff --git a/trushell/cli.py b/trushell/cli.py index 0eb1674..d6f5d3d 100644 --- a/trushell/cli.py +++ b/trushell/cli.py @@ -29,9 +29,6 @@ def app_with_lower() -> None: if len(sys.argv) > 1: argv_copy = sys.argv.copy() if argv_copy[1].lower() not in {"--help", "-h", "version"}: - # Normalize the command name to lowercase for case-insensitive - # invocation, but preserve the case of subsequent arguments - # (e.g., filenames) which may be case-sensitive. first = argv_copy[1].lower() rest = argv_copy[2:] raw = " ".join([first] + rest)