diff options
-rw-r--r-- | hazwaz/command.py | 10 | ||||
-rw-r--r-- | tests/test_command.py | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/hazwaz/command.py b/hazwaz/command.py index 91a2b68..14a8a52 100644 --- a/hazwaz/command.py +++ b/hazwaz/command.py @@ -23,7 +23,7 @@ class MainCommand: The main class for a command line command. Your script will have to subclass this once, instantiate and run its - :py:meth:`main()` e.g. as:: + :py:meth:`run()` e.g. as:: class MyCommand(MainCommand): """ @@ -31,7 +31,7 @@ class MainCommand: """ if __name__ == "__main__": - MyCommand().main() + MyCommand().run() ''' commands = () @@ -43,7 +43,7 @@ class MainCommand: epilog=epilog, ) self.add_arguments(self.parser) - self.parser.set_defaults(func=self._main) + self.parser.set_defaults(func=self.main) self.subparsers = self.parser.add_subparsers() for sub in self.commands: sub_help = _get_first_docstring_line(sub) @@ -56,7 +56,7 @@ class MainCommand: sub.add_arguments(sub_parser) sub_parser.set_defaults(func=sub._main) - def _main(self, args): + def main(self, args): self.parser.print_help() def add_arguments(self, parser: argparse.ArgumentParser): @@ -72,7 +72,7 @@ class MainCommand: help="Show debug messages", ) - def main(self): + def run(self): self.args = self.parser.parse_args() if self.args.debug: diff --git a/tests/test_command.py b/tests/test_command.py index d0b6437..f4e93bb 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -54,7 +54,7 @@ class testCommand(unittest.TestCase): sys.argv = argv with contextlib.redirect_stdout(stream['stdout']): with contextlib.redirect_stderr(stream['stderr']): - cmd.main() + cmd.run() sys.argv = old_argv return stream |