# shellcheck shell=bash disable=SC2034,SC2154
# shellcheck disable=SC2039,3043
xrc:mod:lib fjo     \
    repo/pr/ls  repo/pr/info  repo/pr/create  repo/pr/edit  repo/pr/merge repo/pr/view

___x_cmd_fjo_repo_pr(){
    param:subcmd ___x_cmd_fjo_repo_pr            \
        "ls"                "list pull requests"    \
        "info"              "pull request info"     \
        "create"            "create pull request"   \
        "edit|ed"           "update pull requests"  \
        merge               "merge pull requests"   \
        view                "open browser to view"
    param:subcmd:try
    param:run


    ___x_cmd_fjo_repo_pr _param_help_doc
    return 1
}



___x_cmd_fjo_pr____ui_handler(){
    if [ -n "$ENFORCE_JSON" ] || [ -n "$json" ]; then
        ___x_cmd_cmds_cat
        ___x_cmd_fjo_http_error
        return
    fi

    (
        local data
        local msg
        local error_msg
        case "$1" in
            Info)
                msg="Successfully obtained PR information"
                error_msg="Failed to get PR information"
                ;;
            Creating)
                msg="Successfully obtained PR information"
                error_msg="Failed to get PR information"
                ;;
            Edit)
                msg="Edit PR success"
                error_msg="Failed to Edit PR"
                ;;
        esac
        ___x_cmd jo env . id=.id fjo_resp_err=.message url=.html_url state=.state title=.title body=.body
        if [ -n "$id" ]; then
            ___x_cmd_ui_tf true "$msg" ${url+"Url: $url"}  ${state+"State: $state"} ${title+"Title: $title"} ${body+"Body: $body"}
        else
            ___x_cmd_ui_tf false "$error_msg"
            ___x_cmd_fjo____handle_resp
            return 1
        fi
    )
}