diff --git a/src/mudlib/commands/help.py b/src/mudlib/commands/help.py index b08d59e..84e46bb 100644 --- a/src/mudlib/commands/help.py +++ b/src/mudlib/commands/help.py @@ -274,3 +274,31 @@ register( help="list combat skills", ) ) + + +async def cmd_help(player: Player, args: str) -> None: + """Show help for a command or skill. + + Args: + player: The player executing the command + args: Command name to get help for + """ + args = args.strip() + if not args: + await player.send( + "type help for details. see also: commands, skills\r\n" + ) + return + await _show_command_detail(player, args) + + +# Register the help command +register( + CommandDefinition( + "help", + cmd_help, + aliases=[], + mode="*", + help="show help for a command", + ) +) diff --git a/tests/test_help_command.py b/tests/test_help_command.py index 99ff114..2d7fad7 100644 --- a/tests/test_help_command.py +++ b/tests/test_help_command.py @@ -1,8 +1,9 @@ """Tests for the standalone help command.""" -import pytest from unittest.mock import AsyncMock, MagicMock +import pytest + from mudlib import commands # Import command modules to register their commands @@ -30,9 +31,7 @@ def mock_reader(): def player(mock_reader, mock_writer): from mudlib.player import Player - return Player( - name="TestPlayer", x=5, y=5, reader=mock_reader, writer=mock_writer - ) + return Player(name="TestPlayer", x=5, y=5, reader=mock_reader, writer=mock_writer) @pytest.mark.asyncio @@ -73,7 +72,7 @@ async def test_help_unknown_command_shows_error(player): await commands.dispatch(player, "help nonexistent") output = "".join([call[0][0] for call in player.writer.write.call_args_list]) assert "nonexistent" in output.lower() - assert ("unknown" in output.lower() or "not found" in output.lower()) + assert "unknown" in output.lower() or "not found" in output.lower() @pytest.mark.asyncio @@ -82,4 +81,4 @@ async def test_help_and_commands_both_exist(): assert "help" in commands._registry assert "commands" in commands._registry # They should be different functions - assert commands._registry["help"].func != commands._registry["commands"].func + assert commands._registry["help"].handler != commands._registry["commands"].handler