hazwaz.command module¶
-
class
hazwaz.command.Command[source]¶ Bases:
objectA subcommand to a MainCommand.
Every subcommand of your script will be a subclass of this, added to the
MainCommand.subcommands.-
add_arguments(parser: argparse.ArgumentParser)[source]¶ Add argparse arguments to an existing parser.
Override this method to add arguments to a subcommand.
-
name: Optional[str] = None¶ The name used to call this subcommand from the command line.
If this property is none, the default is the name of the class set to lowercase.
-
-
class
hazwaz.command.MainCommand[source]¶ Bases:
objectThe main class for a command line command.
Your script will have to subclass this once, instantiate and run its
run()e.g. as:class MyCommand(MainCommand): """ A description that will be used in the help. """ if __name__ == "__main__": MyCommand().run()
-
add_arguments(parser: argparse.ArgumentParser)[source]¶ Add argparse arguments to an existing parser.
If you need to override this method, you probably want to call super().add_arguments(parser) to add the default arguments.
-
coloredlogs: bool = True¶ Whether coloredlogs is used (if available)
-
commands: Iterable[hazwaz.command.Command] = ()¶ The subcommands: a tuple of
Commandsubclasses.
-
logformat: str = '%(levelname)s:%(name)s: %(message)s'¶ The format passed to logging.Formatter.
-