def main(): setup() c = argparse.ArgumentParser() c.add_argument( "--version", help="Show the version of BGmi.", action="version", version=print_version(), ) sub_parser = c.add_subparsers(help="BGmi actions", dest="action") for action in actions_and_arguments: tmp_sub_parser = sub_parser.add_parser(action["action"], help=action.get("help", "")) for sub_action in action.get("arguments", []): if isinstance(sub_action["dest"], str): tmp_sub_parser.add_argument(sub_action["dest"], **sub_action["kwargs"]) if isinstance(sub_action["dest"], list): tmp_sub_parser.add_argument(*sub_action["dest"], **sub_action["kwargs"]) sub_parser.add_parser( ACTION_COMPLETE, help='Gen completion, `eval "$(bgmi complete)"` ' 'or `eval "$(bgmi complete|dos2unix)"`', ) # sub_parser_del.add_argument('command', nargs='+', ) ret = c.parse_args() if ret.action == "install": import bgmi.setup bgmi.setup.install() get_web_admin(method="install") raise SystemExit elif ret.action == "upgrade": create_dir() update_database() check_update(mark=False) else: check_update() controllers(ret)
def main(): setup() c = argparse.ArgumentParser() c.add_argument('--version', help='Show the version of BGmi.', action='version', version=print_version()) sub_parser = c.add_subparsers(help='BGmi actions', dest='action') for action in actions_and_arguments: tmp_sub_parser = sub_parser.add_parser(action['action'], help=action.get('help', '')) for sub_action in action.get('arguments', []): if isinstance(sub_action['dest'], string_types): tmp_sub_parser.add_argument(sub_action['dest'], **sub_action['kwargs']) if isinstance(sub_action['dest'], list): tmp_sub_parser.add_argument(*sub_action['dest'], **sub_action['kwargs']) sub_parser.add_parser(ACTION_COMPLETE, help='Gen completion, `eval "$(bgmi complete)"` ' 'or `eval "$(bgmi complete|dos2unix)"`') # sub_parser_del.add_argument('command', nargs='+', ) ret = c.parse_args() if ret.action == 'install': import bgmi.setup bgmi.setup.install() get_web_admin(method='install') raise SystemExit elif ret.action == 'upgrade': create_dir() update_database() check_update(mark=False) else: check_update() controllers(ret)