# shellcheck shell=dash
# https://gitea.com/api/swagger#/organization/orgListTeams
___x_cmd_fjo_team_ls() {
    param:scope     ___x_cmd_fjo
    param:dsl       '
options:
    --org           "org space address(Get all teams of the current user by default)"       <>:Address=""
    --limit         "Results per page"                                                      <>:Numbers="30"
    --page          "Page number of the results to fetch."                                  <>:Numbers="1"
    --json|-j       "output json data"
'
    param:run
    local url="/user/teams"
    if [ -n "$org" ]; then
        url="/orgs/${org##*/}/teams"
    fi

    if ___x_cmd_gx_output_is_format; then
        ___x_cmd_fjo_get_multi "${url}" | ___x_cmd_gx_output_format
    else
        ___x_cmd_fjo_get_multi "${url}" | \
            ___x_cmd jo 2c             .id  .name  .description .organization.name  | \
            ___x_cmd csv header --add   ID   Name   Description  Organization       | \
            if [ -n "$csv" ]; then  ___x_cmd_cmds cat
            else                    ___x_cmd csv app
            fi
    fi
}


