# shellcheck shell=dash disable=SC2120
# https://docs.github.com/en/rest/repos/repos#list-organization-repositories
___x_cmd_gh_org_repo_ls() {
    if ___x_cmd_gx_has_format_args "$@"; then
        ___x_cmd_gh_org_repo_ll "$@"
        return
    fi

    param:scope     ___x_cmd_github
    param:dsl       <<A
options:
    #1          "org space address"                                         <>:Address
    --type      "Specifies the types of repositories you want returned"     <>="all" =  all private public forks sources member
    --sort      "The property to sort the results by"                       <>:UserSort="updated"
    --direction "The order to sort by"                                      <>:Direction="desc"

    --per_page  "Results per page"                                          <>:Number="30"
    --page      "Page number of the results to fetch."                      <>:Number="1"
A
    param:run

    local Address="${1%%/*}"
    if ___x_cmd_gx_is_interactive_env; then
        local ___X_CMD_TUI_TABLE_FINAL_COMMAND
        local ___X_CMD_TUI_TABLE_CUR_LINE
        local ___X_CMD_TUI_TABLE_CUR_ITEM
        ___x_cmd_gh_tui_app --Address "$Address" --type "$type" --sort "$sort" --direction "$direction" --per_page "$per_page" --page "$page" \
            --request-code '___x_cmd_gh_get_multi  "/orgs/$Address/repos" type sort direction' \
            --error-msg "Couldn't find any data by ${Address}" \
            --end ___x_cmd_gh_org_repo_app_status_handler \
            "org.repo.app.awk"
    else
        ___x_cmd_gh_get_multi  "/orgs/$Address/repos" type sort direction per_page page | \
            x jo 2c    .full_name
    fi

}

___x_cmd_gh_org_repo_app_status_handler(){
    if [ "$___X_CMD_TUI_TABLE_FINAL_COMMAND" = "c" ]; then
        ___x_cmd_gh_org_repo_create --org "$Address"
    fi
}

