def __handle_global_args(self, args: list[str]) -> None: # logging verbosity level level = ParserBase.VERBOSE_TO_LOG_LEVEL[min(args.verbose, 2)] LOGGER.setLevel(level) # hades_dir self.__configure_hades_dir(args.hades_dir) # modimporter if args.modimporter: config.modimporter = helpers.try_get_modimporter() else: LOGGER.info("Using '--no-modimporter': will not run 'modimporter', even if available")
def __start(self) -> None: raw_args = sys.argv[1:] args = self.parse_args(raw_args) # handle global args early self.__handle_global_args(args) # if no subcommand is provided, enter interactive mode if not args.subcommand: # if verbosity not set by user, default to INFO logs in interactive if not args.verbose: LOGGER.setLevel(logging.INFO) args = self.__interactive(raw_args) # handle subcommand args via SubcommandBase.dispatch handler try: args.dispatch(**vars(args)) except Exception as e: LOGGER.exception(e) # log any unhandled exception # if in interactive mode, loop until user manually closes self.__restart() if config.interactive_mode else self.__end()