# shellcheck shell=dash

___x_cmd_gl_user_repo(){
    param:subcmd ___x_cmd_gl_user_repo    \
        ls         "List user's repo"
    param:subcmd:try
    param:run

    ___x_cmd_gl_user_repo _param_help_doc
    return 1
}

# Section: List
# http://localhost:4000/13.7/ee/api/projects.html#list-user-projects
# shellcheck disable=2034
___x_cmd_gl_user_repo_ls(){
    param:scope     ___x_cmd_gl
    param:dsl       '
options:
    #1              "user path (default the authenticated user)"           <>=""
    --page          "target page"                                          <>:Per_page="1"
    --per_page      "per page data number"                                 <>:Numbers="30"
    --visibility    "repo visibility"                                      <>=""   = private public internal ""
    --owned         "User owned"

    --json|-j       "output raw JSON data"
'
    param:run
    local _url=""
    if [ -n "$1" ]; then
        _url="/users/$1/projects"
    else
        _url="/projects"
        owned=true
    fi

    if [ -n "$json" ] || [ -n "$ENFORCE_JSON" ]; then
        ___x_cmd_gl_get_multi "$_url" visibility owned
    else
        ___x_cmd_gl_get_multi "$_url" visibility owned | \
            x jo 2c             .id  .path_with_namespace .visibility .default_branch .description | \
            x csv header --add   ID  Repopath   Visibility  Default_Branch  Description | \
            x csv static_tab
    fi
}

# EndSection
