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
17 changes: 7 additions & 10 deletions tests/test_help_docs.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
3 changes: 0 additions & 3 deletions trushell/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down