apps.utils.cli ======================== .. autoapi-nested-parse:: Base classes used for building command line applications. Module Contents --------------- .. py:class:: BaseParser Bases: :py:obj:`argparse.ArgumentParser` Base class for building commandline applications. Child classes should implement the following: 1. The application commandline interface in the ``__init__`` method 2. The primary application logic in the ``app_logic`` method Unless set explicitly, the application description (``self.description``) is pulled from the class docstring. .. py:attribute:: description :value: '' .. py:method:: app_logic(args: argparse.Namespace) -> None :abstractmethod: Logic to evaluate when executing the application :param args: Parsed command line arguments .. py:method:: error(message: str) -> None Handle errors and exit the application This method mimics the parent class behavior except error messages are included in the raised ``SystemExit`` exception. This makes for easier testing/debugging. If the application was called without any commandline arguments, the application help text is printed before exiting. :param message: The error message :raises SystemExit: Every time the method is run .. py:method:: execute(args: Optional[List[str]] = None) -> None :classmethod: Parse command line arguments and execute the application :param args: Optionally parse the given arguments instead of reading STDIN