M CHANGELOG.md => CHANGELOG.md +4 -4
@@ 6,10 6,10 @@ Unreleased
Changes to client API:
-- Root subclasses must now set "rootname" on their base class. It should
- be set toto the name of the root program (i.e. whatever sys.argv[0]
- would be). This is technically only needed if you use the new
- "simple_sub_parser()" method though.
+- Root subclasses can now set "rootname" on their base class. It should
+ be set to the name of the root program (i.e. whatever sys.argv[0] would be).
+ This is technically only needed if you use the new "simple_sub_parser()"
+ method though.
- The optional "help" attribute can be used as a short description, if
you'd like to make description multiline.
- The optional "group" attribute can be set on each class in order to
M subc/__init__.py => subc/__init__.py +5 -5
@@ 137,10 137,6 @@ class Command(ABC):
- alias: used as an optional alias for this command (in case you rename it)
"""
- @abstractproperty
- def rootname(self) -> str:
- """The root command name (only needs to be defined on the parent)"""
-
@property
def help_formatter_class(self) -> t.Type[F]:
return argparse.HelpFormatter
@@ 196,8 192,12 @@ class Command(ABC):
create a parser for use by documentation generators like
sphinx-argparse.
"""
+ if hasattr(self, "rootname"):
+ prog = f"{self.rootname}"
+ else:
+ prog = self.name
parser = argparse.ArgumentParser(
- prog=f"{self.rootname} {self.name}",
+ prog=prog,
description=self.description,
formatter_class=self.help_formatter_class,
)