From 2b25cc9f908e5d9e9446d91abba46f1f5815b293 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Sat, 22 Aug 2009 13:12:26 -0700 Subject: [PATCH] Help now accepts command shortcuts. --- src/py65/monitor.py | 4 ++++ src/py65/tests/test_monitor.py | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/py65/monitor.py b/src/py65/monitor.py index 0cbf87e..708617b 100644 --- a/src/py65/monitor.py +++ b/src/py65/monitor.py @@ -124,6 +124,10 @@ class Monitor(cmd.Cmd): if stuff is not None: self.stdout.write(stuff + "\n") + def do_help(self, args): + args = self._shortcuts.get(args.strip(), args) + return cmd.Cmd.do_help(self, args) + def help_version(self): self._output("version\t\tDisplay Py65 version information.") diff --git a/src/py65/tests/test_monitor.py b/src/py65/tests/test_monitor.py index 4c8cb19..64f0eac 100644 --- a/src/py65/tests/test_monitor.py +++ b/src/py65/tests/test_monitor.py @@ -99,6 +99,21 @@ class MonitorTests(unittest.TestCase): out = stdout.getvalue() self.assertTrue(out.startswith("assemble
")) + # help + + def test_help_accepts_command_shortcuts(self): + stdout = StringIO() + mon = Monitor(stdout=stdout) + + mon.onecmd("help assemble \t ") + help_for_command = stdout.getvalue() + + stdout.truncate(0) + mon.onecmd("help a \t ") + help_for_shortcut = stdout.getvalue() + + self.assertEqual(help_for_command, help_for_shortcut) + # mpu def test_mpu_with_no_args_prints_current_lists_available_mpus(self):