summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2022-03-11 09:20:19 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2022-03-11 09:20:19 +0100
commit6f68b21fc6e2f675ea83c4b96df93fcf7edc54dd (patch)
tree1a97f7842fa3acf5c7943f288f97fa371cc09c5b
parentb3ce304e2857bf729dafc064a87e87a25cf0788e (diff)
Rename the main for a MainCommand to make it more consistent with (sub)Commands.
-rw-r--r--hazwaz/command.py10
-rw-r--r--tests/test_command.py2
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