# shellcheck shell=dash disable=SC2034,SC2154
# https://gitea.com/api/swagger#/repository/repoCreateReleaseAttachment
___x_cmd_fjo_repo_release_attachment_upload() {
    param:scope     ___x_cmd_fjo
    param:dsl    '
options:
    #1              "target upload attachment file path"            <>
    --repo|-r       "<owner_path>/<repo_path>"                      <>:RepoName
    --release_id    "Release ID"                                    <>:Number
    --name          "name of the attachment"                        <>=""
'
    param:run
    ___x_cmd_fjo_param_init_owner_repo
    [ -n "$1" ] || M='accepts 1 arg (target upload attachment file path), received empty' arg:ret:64
    local _file_path="$1"
    [ "$_file_path" != '-' ] || _file_path="$(___x_cmd_cmds_cat)"

    ___x_cmd_fjo_curl upload "/repos/${owner_repo}/releases/${release_id##*/}/assets${name:+"?name=$name"}" "$_file_path" \
        | ___x_cmd_fjo_release_attachment_____ui_handler Upload
}
