# shellcheck shell=dash

# https://gitea.com/api/swagger#/issue/issueListIssues
___x_cmd_fjo_issue_ls(){
    param:scope     ___x_cmd_fjo
    param:dsl       '
options:
    --repo|-r          "<owner_path>/<repo_path>"                                                                   <>:RepoName
    --q                "search string"                                                                              <>=""
    --state            "Indicates the state of the issues to return."                                               <>="all"      = open closed all
    --labels           "Labels to associate with this issue.(separated by commas)"                                  <>=""
    --type             "filter by type (issues / pulls) if set."                                                    <>=""         = issues pulls
    --since            "Only show items updated after the given time. This is a timestamp in RFC 3339 format"       <>=""
    --before           "Only show items updated before the given time. This is a timestamp in RFC 3339 format"      <>=""
    --created_by       "Only show items which were created by the the given user"                                   <>=""
    --assigned_by      "Only show items for which the given user is assigned"                                       <>=""
    --milestones       "comma separated list of milestone names or ids"                                             <>=""
    --mentioned_by     "Only show items in which the given user was mentioned"                                      <>=""
    --limit            "Results per page"                                                                           <>:Numbers="30"
    --page             "Page number of the results to fetch."                                                       <>:Numbers="1"

    --json|-j          "output origin json data"
    --csv              "output csv data"
    --yml              "output yml data"
'
    param:run

    ___x_cmd_fjo_param_init_owner_repo

    [ -n "$owner_repo" ] || M='Please provide --repo <owner/repo>"' arg:ret:64
    if ___x_cmd_gx_output_is_format; then
        ___x_cmd_fjo_issue_ls___raw | ___x_cmd_gx_output_format
    else
        ___x_cmd_fjo_issue_ls___raw | \
            ___x_cmd jo 2c            .number  .state   .title | \
            ___x_cmd csv header --add  Number   State    Title | \
            if [ -n "$csv" ]; then  ___x_cmd_cmds cat
            else                    ___x_cmd csv static_tab
            fi
    fi
}


___x_cmd_fjo_issue_ls___yml(){
    :
}


___x_cmd_fjo_issue_ls___csv(){
    :
}

___x_cmd_fjo_issue_ls___json(){
    :
}

___x_cmd_fjo_issue_ls___raw(){
    ___x_cmd_fjo_get_multi "/repos/${owner_repo}/issues" q type state milestones labels since before created_by assigned_by mentioned_by
}
