def make_argument_parser()

in lib/ramble/ramble/main.py [0:0]


def make_argument_parser(**kwargs):
    """Create an basic argument parser without any subcommands added."""
    parser = RambleArgumentParser(
        formatter_class=RambleHelpFormatter,
        add_help=False,
        description=("A flexible benchmark experiment manager."),
        **kwargs,
    )

    # stat names in groups of 7, for nice wrapping.
    stat_lines = list(zip(*(iter(stat_names),) * 7))

    parser.add_argument(
        "-h",
        "--help",
        dest="help",
        action="store_const",
        const="short",
        default=None,
        help="show this help message and exit",
    )
    parser.add_argument(
        "-H",
        "--all-help",
        dest="help",
        action="store_const",
        const="long",
        default=None,
        help="show help for all commands (same as ramble help --all)",
    )
    parser.add_argument(
        "--color",
        action="store",
        default=os.environ.get("RAMBLE_COLOR", "auto"),
        choices=("always", "never", "auto"),
        help="when to colorize output (default: auto)",
    )
    parser.add_argument(
        "-c",
        "--config",
        default=None,
        action="append",
        dest="config_vars",
        help="add one or more custom, one off config settings.",
    )
    parser.add_argument(
        "-C",
        "--config-scope",
        dest="config_scopes",
        action="append",
        metavar="DIR",
        help="add a custom configuration scope",
    )
    parser.add_argument(
        "-d",
        "--debug",
        action="count",
        default=0,
        help="write out debug messages " "(more d's for more verbosity: -d, -dd, -ddd, etc.)",
    )
    parser.add_argument(
        "--disable-passthrough",
        action="store_true",
        help="disable passthrough of expansion variables for debugging",
    )
    parser.add_argument(
        "-N",
        "--disable-logger",
        action="store_true",
        help="disable the ramble logger. All output will be printed to stdout.",
    )
    parser.add_argument(
        "-P",
        "--disable-progress-bar",
        action="store_true",
        help="disable the progress bars while setting up experiments.",
    )

    parser.add_argument("--timestamp", action="store_true", help="Add a timestamp to tty output")
    parser.add_argument("--pdb", action="store_true", help="run ramble under the pdb debugger")

    workspace_group = parser.add_mutually_exclusive_group()
    workspace_group.add_argument(
        "-w",
        "--workspace",
        dest="workspace",
        metavar="WRKSPC",
        action="store",
        help="run with a specific workspace (see ramble workspace)",
    )
    workspace_group.add_argument(
        "-D",
        "--workspace-dir",
        dest="workspace_dir",
        metavar="DIR",
        action="store",
        help="run with a workspace directory (ignore named workspaces)",
    )
    workspace_group.add_argument(
        "-W",
        "--no-workspace",
        dest="no_workspace",
        action="store_true",
        help="run without any workspaces activated (see ramble workspace)",
    )
    parser.add_argument(
        "--use-workspace-repo",
        action="store_true",
        help="when running in a workspace, use its application repository",
    )

    parser.add_argument(
        "--resolve-variables-in-subprocesses",
        action="store_true",
        help="Allow resolution of environment variables when launching subprocesses",
    )

    parser.add_argument(
        "-k",
        "--insecure",
        action="store_true",
        help="do not check ssl certificates when downloading",
    )
    parser.add_argument(
        "-l",
        "--enable-locks",
        action="store_true",
        dest="locks",
        default=None,
        help="use filesystem locking (default)",
    )
    parser.add_argument(
        "-L",
        "--disable-locks",
        action="store_false",
        dest="locks",
        help="do not use filesystem locking (unsafe)",
    )
    parser.add_argument(
        "-m",
        "--mock",
        action="store_true",
        help="use the builtin.mock repository instead of builtin",
    )

    for obj in ramble.repository.ObjectTypes:
        objname = obj.name.replace("_", "-")
        print_name = obj.name.replace("_", " ")
        parser.add_argument(
            f"--mock-{objname}",
            action="store_true",
            help=f"use mock {print_name} instead of real ones",
        )

    # TODO (dwj): Do we need this?
    # parser.add_argument(
    #   # '-b', '--bootstrap', action='store_true',
    #   # help="use bootstrap configuration (bootstrap store, config, externals)")
    parser.add_argument(
        "-p",
        "--profile",
        action="store_true",
        dest="ramble_profile",
        help="profile execution using cProfile",
    )
    parser.add_argument(
        "--sorted-profile",
        default=None,
        metavar="STAT",
        help="profile and sort by one or more of:\n[%s]"
        % ",\n ".join([", ".join(line) for line in stat_lines]),
    )
    parser.add_argument(
        "--lines",
        default=20,
        action="store",
        help="lines of profile output or 'all' (default: 20)",
    )
    parser.add_argument(
        "--profile-restrictions",
        default="",
        action="store",
        help=(
            "Comma-separated restrictions applied to the cProfiler. "
            "When specified, it takes precedence over `--lines`. "
            "Example: `--profile-restrictions 'logger,5'` limits the list to functions with "
            "'logger' in the path, and then shows the first 5 of them. "
            "See https://docs.python.org/3/library/profile.html#pstats.Stats.print_stats for more "
            "details."
        ),
    )
    parser.add_argument(
        "-v", "--verbose", action="store_true", help="print additional output during builds"
    )
    parser.add_argument(
        "--stacktrace",
        action="store_true",
        default="RAMBLE_STACKTRACE" in os.environ,
        help="add stacktraces to all printed statements",
    )
    parser.add_argument(
        "-V", "--version", action="store_true", help="show version number and exit"
    )
    parser.add_argument(
        "--print-shell-vars", action="store", help="print info needed by setup-env.[c]sh"
    )

    return parser