Skip to content

Commit

Permalink
Merge pull request #57 from TheFriendlyCoder/help_alias
Browse files Browse the repository at this point in the history
Fixes #36 Added alias for help method
  • Loading branch information
TheFriendlyCoder committed May 7, 2018
2 parents 54ed2e2 + 591f495 commit 41cba77
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/friendlyshell/shell_help_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ def help_help(self):
"example: " + self.prompt + "help exit"
]
return '\n'.join(retval)

@staticmethod
def alias_help():
"""Gets short hand character for the help command
:rtype: :class:`str`
"""
return "?"
17 changes: 17 additions & 0 deletions tests/test_help_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ def do_something(self):
obj.run()
assert "Here's online help" in caplog.text


def test_help_alias(caplog):
caplog.set_level(logging.INFO)

class MyShell(BasicLoggerMixin, BaseShell, ShellHelpMixin):
def do_something(self):
"""Here's online help"""
pass

obj = MyShell()

with patch('friendlyshell.base_shell.input') as MockInput:
MockInput.side_effect = ['? something', 'exit']
obj.run()
assert "Here's online help" in caplog.text


def test_command_help(caplog):
caplog.set_level(logging.INFO)
expected_help = "Here's my verbose help for something..."
Expand Down

0 comments on commit 41cba77

Please sign in to comment.