def get_parser(): ap = argparse.ArgumentParser() subparsers = ap.add_subparsers(dest="action", help="run/info/report") # subparser run ap_run = subparsers.add_parser("run", help="run script") runner_parser(ap_run) # subparser info ap_info = subparsers.add_parser("info", help="get & print author/title/desc info of script") ap_info.add_argument("script", help="script filename") # subparser report ap_report = subparsers.add_parser("report", help="generate report of script") report_parser(ap_report) return ap
def cli_setup(args=None): """future api for setup env by cli""" if not args: if len(sys.argv) < 2: print("no cmdline args") return False args = sys.argv print(args) ap = argparse.ArgumentParser() if "--report" in args: from airtest.report.report import main as report_main ap = report_parser(ap) args = ap.parse_args(args) report_main(args) exit(0) else: ap = runner_parser(ap) args = ap.parse_args(args) setup_by_args(args) return True