def parse_args()

in tools/release/publish_release.py [0:0]


def parse_args(args):
    parser = argparse.ArgumentParser("Publish releases of buck to github")
    parser.add_argument(
        "--valid-git-upstreams",
        default=(
            "git@github.com:facebook/buck.git",
            "https://github.com/facebook/buck.git",
        ),
        nargs="+",
        help="List of valid upstreams for the git repository in order to publish",
    )
    parser.add_argument(
        "--github-token-file",
        default=os.path.expanduser("~/.buck-github-token"),
        help="A file containing the github token to use",
    )
    parser.add_argument(
        "--github-token",
        help="If provided, use this github token instead of the one in `--github-token-file`",
    )
    parser.add_argument(
        "--repository",
        default="facebook/buck",
        help="The github repository to operate on",
    )
    parser.add_argument(
        "--tap-repository", default="facebook/fb", help="The tap to use for homebrew"
    )
    parser.add_argument(
        "--version",
        default=datetime.datetime.now().strftime("%Y.%m.%d.01"),
        help=(
            "Version to use in git tags and github releases. This is generated "
            "by default"
        ),
    )
    parser.add_argument(
        "--use-existing-release",
        action="store_true",
        help=(
            "If specified, use an existing release (specified by --version), rather "
            "than pushing tags and creating a new release"
        ),
    )
    parser.add_argument(
        "--release-message",
        help=(
            "If specified, use this for the release message. If not specified, "
            "and a new release is created, user will be prompted for a message"
        ),
    )
    parser.add_argument(
        "--no-prompt-for-message",
        help="If set, use a default message rather than prompting for a message",
        action="store_false",
        dest="prompt_for_message",
    )
    parser.add_argument(
        "--no-build-deb",
        dest="build_deb",
        action="store_false",
        help="Do not build deb packages for this release",
    )
    parser.add_argument(
        "--no-build-homebrew",
        dest="build_homebrew",
        action="store_false",
        help="Do not build homebrew packages for this release",
    )
    parser.add_argument(
        "--no-build-chocolatey",
        dest="build_chocolatey",
        action="store_false",
        help="Do not build chocolatey packages for this release",
    )
    parser.add_argument(
        "--deb-file",
        help="Upload this file as the deb for this release. Implies --no-build-deb",
    )
    parser.add_argument(
        "--homebrew-file",
        help="Upload this file as the bottle for this release. Implies --no-build-homebrew",
    )
    parser.add_argument(
        "--chocolatey-file",
        help="Upload this file as the nupkg for this release. Implies --no-build-chocolatey",
    )
    parser.add_argument(
        "--docker-linux-host",
        help="If provided, the docker:port to connect to to build linux images",
    )
    parser.add_argument(
        "--docker-windows-host",
        help="If provided, the docker:port to connect to to build windows images",
    )
    parser.add_argument(
        "--docker-windows-memory",
        default="4g",
        help="The memory argument to pass to docker for windows containers",
    )
    parser.add_argument(
        "--docker-windows-isolation",
        default="process",
        help="The --isolation= argument for windows docker commands",
    )
    parser.add_argument(
        "--keep-temp-files",
        action="store_true",
        help="Keep temporary files regardless of success/failure",
    )
    parser.add_argument(
        "--no-upload-assets",
        dest="upload_assets",
        action="store_false",
        help="Do not upload assets",
    )
    parser.add_argument(
        "--homebrew-target-macos-version",
        default=TARGET_MACOS_VERSION,
        help="The target macos version to use in homebrew specs",
    )
    parser.add_argument(
        "--homebrew-target-macos-version-spec",
        default=TARGET_MACOS_VERSION_SPEC,
        help="The target macos version spec to use in homebrew specs",
    )
    parser.add_argument(
        "--no-homebrew-push-tap",
        dest="homebrew_push_tap",
        action="store_false",
        help="Do not push the homebrew tap. A manual commit will have to be made",
    )
    parser.add_argument(
        "--no-chocolatey-publish",
        dest="chocolatey_publish",
        action="store_false",
        help="Do not publish to chocolatey's community stream",
    )
    parser.add_argument(
        "--chocolatey-token",
        help="If provided, use this chocolatey token instead of the one in `--chocolatey-token-file`",
    )
    parser.add_argument(
        "--chocolatey-token-file",
        default=os.path.expanduser("~/.buck-chocolatey-token"),
        help="A file containing the chocolatey token to use",
    )
    parser.add_argument(
        "--output-dir",
        help=(
            "If specified, artifacts will be written to this directory, instead of "
            "a temporary one"
        ),
    )
    parser.add_argument(
        "--homebrew-dir",
        help=(
            "Where homebrew is (e.g. /usr/local). If not specified, homebrew will be "
            "installed in a separate, temporary directory that gets cleaned up after "
            "building (unless --keep-temp-files is specified). If --output-dir is "
            "specified, homebrew will be installed in a subdirectory there. This can "
            "be useful to ensure that tap directories are preserved and can be "
            "validated and pushed to github if a first run fails, or if a "
            "--no-upload-asset run is done"
        ),
    )
    parser.add_argument(
        "--insecure-chocolatey-upload",
        action="store_true",
        help=(
            "Do less certificate verification when uploading to chocolatey. "
            "This is a workaround for "
            "https://github.com/chocolatey/chocolatey.org/issues/584"
        ),
    )
    parser.add_argument(
        "--docker-login",
        action="store_true",
        help="If set, run 'docker login' using DOCKERHUB_USERNAME and DOCKERHUB_TOKEN",
    )
    parsed_kwargs = dict(parser.parse_args(args)._get_kwargs())
    if parsed_kwargs["deb_file"]:
        parsed_kwargs["build_deb"] = False
    if parsed_kwargs["homebrew_file"]:
        parsed_kwargs["build_homebrew"] = False
    if parsed_kwargs["chocolatey_file"]:
        parsed_kwargs["build_chocolatey"] = False
    return argparse.Namespace(**parsed_kwargs)