示例#1
0
    def main(self, args=None):
        """
        Launch the commandline interface.

        :param args: Optionally pass arguments. If not given, the arguments passed to the program will be parsed.
        """
        self._configure_parser()
        argcomplete.autocomplete(self.parser)
        args = self.parser.parse_args(args)
        logwood.basic_config(
            format='%(timestamp).6f %(level)-5s %(name)s: %(message)s',
            level=self._get_loglevel(args),
        )

        if not args.command:
            self.parser.print_usage()
            sys.exit(1)
        else:
            command = self._commands[args.command]
            if command.needs_app:
                app = Application()
                self.register_application_components(args, app)
                command.__call__(args, app)
            else:
                command.__call__(args)
示例#2
0
def app(configure_logging) -> Application:
    return Application()