#!/usr/bin/env python

import click
import git_utils


@click.command()
@click.option("--short", is_flag=True, default=False,
              help="Show only the PR ID not the full URL of the PR")
@click.argument("branch_name", default="<empty>", nargs=1)
@click.option("-v", "--version",
              help="Use a specific version, not the current branch name.",
              default="<empty>")
def main(short: bool, branch_name: str, version: str) -> None:
    if branch_name == "<empty>":
        branch_name = git_utils.get_checked_out_branch_name()

    if version != "<empty>":
        branch_name = git_utils.get_branch_name_for_different_version(branch_name, version)

    pr_number, pr_url = git_utils.get_github_pr(branch_name)

    if short:
        print(pr_number)
        return

    print(pr_url)


if __name__ == "__main__":
    main()
