import argparse import sys usage = ' %(prog)s [-h] [--bindpwdfile BINDPWDFILE] [--username USERNAME] [-l | -t T [T ...] -s S [S ...]]' parser = argparse.ArgumentParser(description='Executes the diagnostic module checks', usage=usage) parser.add_argument("--bindpwdfile", help='Path to a file that contains your password') parser.add_argument("--username", help='Domain Admin username for Authentication') parser.add_argument('-l', '--list', action='store_true', help='List all available tests and exit') parser.add_argument('-t', '--test', default=['all'], nargs='+', dest='tests', type=str, help='List of tests to be performed. Default is: all') parser.add_argument('-s', '--skip', default=[], nargs='+', dest='skip_tests', type=str, help='List of tests to be skipped. Default is: []') args = parser.parse_args() # fake plugin list for the purpose of the test plugins = [f"plugin_{i}" for i in range(1, 6)] if args.list: print("\n\t".join(['Available tests:'] + plugins)) sys.exit(0) if 'all' in args.tests: args.tests = plugins if args.skip_tests: tests = list(set(plugins) - set(args.skip_tests)) tests.sort() args.tests = tests print(args)