# shellcheck shell=dash disable=SC2034,SC2154,SC2016
# https://gitea.com/api/swagger#/repository/createCurrentUserRepo
___x_cmd_fjo_user_repo_create() {
    param:scope     ___x_cmd_fjo
    param:dsl       '
type:
    access  =   private public
option:
    #1                   "repo names"                                                                       <>
    --access             "private,public"                                                                   <>:access=private
    --readme             "Readme of the repository to create"                                               <>=""
    --license            "License to use"                                                                   <>=""
    --description        "Description of the repository to create"                                          <>=""
    --gitignores         "Gitignores to use"                                                                <>=""
    --issue_labels       "Label-Set to use"                                                                 <>=""
    --trust_model        "TrustModel of the repository"                                                     <>=""      = default collaborator committer collaboratorcommitter
    --default_branch     "Default Branch of the repository (used when initializes and in template)"         <>=""
    --template           "Whether the repository is template"
    --auto_init          "Whether the repository should be auto-initialized"
    --json|-j            "output json data"
'
    param:run

    local private=true
    [ "$access" = "public" ] && private=false

    local name="${___X_CMD_TX}"
    local gen_fjo_json
    gen_fjo_json="$(param:option2json -access +private +name 'template=^^template' 'auto_init=^^auto_init' )"
    for name in "$@"; do
        fjo:debug "$(x tmpl "$gen_fjo_json"  "${name##%/}")"
        x tmpl "$gen_fjo_json"  "${name##%/}" | ___x_cmd_fjo_curl post "/user/repos" "@-" | ___x_cmd_fjo_repo____ui_handler Creating
    done
}

