Add the mred CLI over the library, with flags accepted after positionals
issue list/show/create/update, version list/create, category list/create, relation create. Names resolve case-insensitively against server enumerations; -o json everywhere; exit 0/1/2 with one-line stderr carrying the http status for API failures.
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -308,13 +309,14 @@ func (s *Server) listIssues(q url.Values) (int, string) {
|
||||
}
|
||||
}
|
||||
type out struct {
|
||||
Issues []Issue `json:"issues"`
|
||||
Total int `json:"total_count"`
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
Issues []map[string]any `json:"issues"`
|
||||
Total int `json:"total_count"`
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
o := out{Limit: limit}
|
||||
for _, i := range s.issues {
|
||||
var ids []int
|
||||
for id, i := range s.issues {
|
||||
if proj != "" && i.ProjectID != proj {
|
||||
continue
|
||||
}
|
||||
@@ -327,7 +329,11 @@ func (s *Server) listIssues(q url.Values) (int, string) {
|
||||
if ver != "" && strconv.Itoa(i.FixedVersionID) != ver {
|
||||
continue
|
||||
}
|
||||
o.Issues = append(o.Issues, *i)
|
||||
ids = append(ids, id)
|
||||
}
|
||||
sort.Ints(ids)
|
||||
for _, id := range ids {
|
||||
o.Issues = append(o.Issues, issueView(s, *s.issues[id], false))
|
||||
}
|
||||
o.Total = len(o.Issues)
|
||||
if len(o.Issues) > limit {
|
||||
|
||||
Reference in New Issue
Block a user