2018-07-14 23:19:05 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2020-06-14 03:41:50 +03:00
|
|
|
"encoding/json"
|
2018-07-14 23:19:05 +03:00
|
|
|
"fmt"
|
2020-07-12 19:53:24 +03:00
|
|
|
"regexp"
|
2018-09-19 22:50:03 +03:00
|
|
|
"strings"
|
2020-06-28 20:09:32 +03:00
|
|
|
"time"
|
2018-08-13 19:32:11 +03:00
|
|
|
|
2019-11-03 16:00:35 +03:00
|
|
|
text "github.com/MichaelMure/go-term-text"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2020-03-14 18:47:38 +03:00
|
|
|
"github.com/MichaelMure/git-bug/bug"
|
2018-09-02 16:46:43 +03:00
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2020-03-14 18:47:38 +03:00
|
|
|
"github.com/MichaelMure/git-bug/query"
|
2018-09-11 23:04:16 +03:00
|
|
|
"github.com/MichaelMure/git-bug/util/colors"
|
2018-07-14 23:19:05 +03:00
|
|
|
)
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
type lsOptions struct {
|
|
|
|
query query.Query
|
|
|
|
|
|
|
|
statusQuery []string
|
|
|
|
noQuery []string
|
|
|
|
sortBy string
|
|
|
|
sortDirection string
|
|
|
|
outputFormat string
|
|
|
|
}
|
|
|
|
|
|
|
|
func newLsCommand() *cobra.Command {
|
|
|
|
env := newEnv()
|
|
|
|
options := lsOptions{}
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
2020-07-28 21:24:24 +03:00
|
|
|
Use: "ls [QUERY]",
|
2020-06-28 19:26:29 +03:00
|
|
|
Short: "List bugs.",
|
|
|
|
Long: `Display a summary of each bugs.
|
|
|
|
|
|
|
|
You can pass an additional query to filter and order the list. This query can be expressed either with a simple query language or with flags.`,
|
|
|
|
Example: `List open bugs sorted by last edition with a query:
|
|
|
|
git bug ls status:open sort:edit-desc
|
|
|
|
|
|
|
|
List closed bugs sorted by creation with flags:
|
|
|
|
git bug ls --status closed --by creation
|
|
|
|
`,
|
2020-06-28 20:09:32 +03:00
|
|
|
PreRunE: loadBackend(env),
|
|
|
|
PostRunE: closeBackend(env),
|
2020-06-28 19:26:29 +03:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
return runLs(env, options, args)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
flags := cmd.Flags()
|
|
|
|
flags.SortFlags = false
|
2018-09-10 19:16:16 +03:00
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
flags.StringSliceVarP(&options.statusQuery, "status", "s", nil,
|
|
|
|
"Filter by status. Valid values are [open,closed]")
|
|
|
|
flags.StringSliceVarP(&options.query.Author, "author", "a", nil,
|
|
|
|
"Filter by author")
|
|
|
|
flags.StringSliceVarP(&options.query.Participant, "participant", "p", nil,
|
|
|
|
"Filter by participant")
|
|
|
|
flags.StringSliceVarP(&options.query.Actor, "actor", "A", nil,
|
|
|
|
"Filter by actor")
|
|
|
|
flags.StringSliceVarP(&options.query.Label, "label", "l", nil,
|
|
|
|
"Filter by label")
|
|
|
|
flags.StringSliceVarP(&options.query.Title, "title", "t", nil,
|
|
|
|
"Filter by title")
|
|
|
|
flags.StringSliceVarP(&options.noQuery, "no", "n", nil,
|
|
|
|
"Filter by absence of something. Valid values are [label]")
|
|
|
|
flags.StringVarP(&options.sortBy, "by", "b", "creation",
|
|
|
|
"Sort the results by a characteristic. Valid values are [id,creation,edit]")
|
|
|
|
flags.StringVarP(&options.sortDirection, "direction", "d", "asc",
|
|
|
|
"Select the sorting direction. Valid values are [asc,desc]")
|
|
|
|
flags.StringVarP(&options.outputFormat, "format", "f", "default",
|
|
|
|
"Select the output formatting style. Valid values are [default,plain,json,org-mode]")
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func runLs(env *Env, opts lsOptions, args []string) error {
|
2020-03-22 15:53:34 +03:00
|
|
|
var q *query.Query
|
2020-06-28 20:09:32 +03:00
|
|
|
var err error
|
|
|
|
|
2018-09-09 21:22:46 +03:00
|
|
|
if len(args) >= 1 {
|
2020-03-14 18:47:38 +03:00
|
|
|
q, err = query.Parse(strings.Join(args, " "))
|
2018-09-09 21:22:46 +03:00
|
|
|
|
2018-09-10 19:16:16 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
2020-06-28 19:26:29 +03:00
|
|
|
err = completeQuery(&opts)
|
2018-09-09 21:22:46 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-06-28 19:26:29 +03:00
|
|
|
q = &opts.query
|
2018-09-09 21:22:46 +03:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:09:32 +03:00
|
|
|
allIds := env.backend.QueryBugs(q)
|
2018-07-14 23:19:05 +03:00
|
|
|
|
2020-06-14 03:41:50 +03:00
|
|
|
bugExcerpt := make([]*cache.BugExcerpt, len(allIds))
|
|
|
|
for i, id := range allIds {
|
2020-06-28 20:09:32 +03:00
|
|
|
b, err := env.backend.ResolveBugExcerpt(id)
|
2018-09-02 16:46:43 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-07-14 23:19:05 +03:00
|
|
|
}
|
2020-06-14 03:41:50 +03:00
|
|
|
bugExcerpt[i] = b
|
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
switch opts.outputFormat {
|
2020-06-23 12:51:42 +03:00
|
|
|
case "org-mode":
|
2020-06-28 20:09:32 +03:00
|
|
|
return lsOrgmodeFormatter(env, bugExcerpt)
|
2020-06-14 03:41:50 +03:00
|
|
|
case "plain":
|
2020-06-28 20:09:32 +03:00
|
|
|
return lsPlainFormatter(env, bugExcerpt)
|
2020-06-14 03:41:50 +03:00
|
|
|
case "json":
|
2020-06-28 20:09:32 +03:00
|
|
|
return lsJsonFormatter(env, bugExcerpt)
|
2020-06-14 03:41:50 +03:00
|
|
|
case "default":
|
2020-06-28 20:09:32 +03:00
|
|
|
return lsDefaultFormatter(env, bugExcerpt)
|
2020-06-14 03:41:50 +03:00
|
|
|
default:
|
2020-06-28 19:26:29 +03:00
|
|
|
return fmt.Errorf("unknown format %s", opts.outputFormat)
|
2020-06-14 03:41:50 +03:00
|
|
|
}
|
|
|
|
}
|
2018-07-14 23:19:05 +03:00
|
|
|
|
2020-06-21 08:51:48 +03:00
|
|
|
type JSONBugExcerpt struct {
|
2020-06-26 00:18:17 +03:00
|
|
|
Id string `json:"id"`
|
|
|
|
HumanId string `json:"human_id"`
|
|
|
|
CreateTime JSONTime `json:"create_time"`
|
|
|
|
EditTime JSONTime `json:"edit_time"`
|
2020-06-14 03:41:50 +03:00
|
|
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
Labels []bug.Label `json:"labels"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Actors []JSONIdentity `json:"actors"`
|
|
|
|
Participants []JSONIdentity `json:"participants"`
|
|
|
|
Author JSONIdentity `json:"author"`
|
|
|
|
|
|
|
|
Comments int `json:"comments"`
|
|
|
|
Metadata map[string]string `json:"metadata"`
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:09:32 +03:00
|
|
|
func lsJsonFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
|
2020-06-21 08:51:48 +03:00
|
|
|
jsonBugs := make([]JSONBugExcerpt, len(bugExcerpts))
|
2020-06-17 03:34:36 +03:00
|
|
|
for i, b := range bugExcerpts {
|
2020-06-21 08:51:48 +03:00
|
|
|
jsonBug := JSONBugExcerpt{
|
2020-06-26 00:18:17 +03:00
|
|
|
Id: b.Id.String(),
|
|
|
|
HumanId: b.Id.Human(),
|
|
|
|
CreateTime: NewJSONTime(b.CreateTime(), b.CreateLamportTime),
|
|
|
|
EditTime: NewJSONTime(b.EditTime(), b.EditLamportTime),
|
|
|
|
Status: b.Status.String(),
|
|
|
|
Labels: b.Labels,
|
|
|
|
Title: b.Title,
|
|
|
|
Comments: b.LenComments,
|
|
|
|
Metadata: b.CreateMetadata,
|
2020-06-14 03:41:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if b.AuthorId != "" {
|
2020-06-28 20:09:32 +03:00
|
|
|
author, err := env.backend.ResolveIdentityExcerpt(b.AuthorId)
|
2020-06-14 03:41:50 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-06-24 15:52:48 +03:00
|
|
|
jsonBug.Author = NewJSONIdentityFromExcerpt(author)
|
2020-06-14 03:41:50 +03:00
|
|
|
} else {
|
2020-06-24 15:52:48 +03:00
|
|
|
jsonBug.Author = NewJSONIdentityFromLegacyExcerpt(&b.LegacyAuthor)
|
2020-06-14 03:41:50 +03:00
|
|
|
}
|
|
|
|
|
2020-06-24 15:52:48 +03:00
|
|
|
jsonBug.Actors = make([]JSONIdentity, len(b.Actors))
|
|
|
|
for i, element := range b.Actors {
|
2020-06-28 20:09:32 +03:00
|
|
|
actor, err := env.backend.ResolveIdentityExcerpt(element)
|
2020-06-14 03:41:50 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-06-24 15:52:48 +03:00
|
|
|
jsonBug.Actors[i] = NewJSONIdentityFromExcerpt(actor)
|
2020-06-14 03:41:50 +03:00
|
|
|
}
|
|
|
|
|
2020-06-24 15:52:48 +03:00
|
|
|
jsonBug.Participants = make([]JSONIdentity, len(b.Participants))
|
|
|
|
for i, element := range b.Participants {
|
2020-06-28 20:09:32 +03:00
|
|
|
participant, err := env.backend.ResolveIdentityExcerpt(element)
|
2020-06-14 03:41:50 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-06-24 15:52:48 +03:00
|
|
|
jsonBug.Participants[i] = NewJSONIdentityFromExcerpt(participant)
|
2020-06-14 03:41:50 +03:00
|
|
|
}
|
|
|
|
|
2020-06-17 03:34:36 +03:00
|
|
|
jsonBugs[i] = jsonBug
|
2020-06-14 03:41:50 +03:00
|
|
|
}
|
2020-06-17 03:34:36 +03:00
|
|
|
jsonObject, _ := json.MarshalIndent(jsonBugs, "", " ")
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Printf("%s\n", jsonObject)
|
2020-06-14 03:41:50 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:09:32 +03:00
|
|
|
func lsDefaultFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
|
2020-06-14 03:41:50 +03:00
|
|
|
for _, b := range bugExcerpts {
|
2019-04-11 21:04:44 +03:00
|
|
|
var name string
|
|
|
|
if b.AuthorId != "" {
|
2020-06-28 20:09:32 +03:00
|
|
|
author, err := env.backend.ResolveIdentityExcerpt(b.AuthorId)
|
2019-04-11 21:04:44 +03:00
|
|
|
if err != nil {
|
2020-06-14 03:41:50 +03:00
|
|
|
return err
|
2019-04-11 21:04:44 +03:00
|
|
|
}
|
2020-06-14 03:41:50 +03:00
|
|
|
name = author.DisplayName()
|
2019-04-11 21:04:44 +03:00
|
|
|
} else {
|
|
|
|
name = b.LegacyAuthor.DisplayName()
|
|
|
|
}
|
|
|
|
|
2019-11-03 16:00:35 +03:00
|
|
|
var labelsTxt strings.Builder
|
2019-10-28 14:43:24 +03:00
|
|
|
for _, l := range b.Labels {
|
2019-11-03 16:00:35 +03:00
|
|
|
lc256 := l.Color().Term256()
|
|
|
|
labelsTxt.WriteString(lc256.Escape())
|
|
|
|
labelsTxt.WriteString(" ◼")
|
|
|
|
labelsTxt.WriteString(lc256.Unescape())
|
2019-10-28 14:43:24 +03:00
|
|
|
}
|
|
|
|
|
2018-07-17 21:23:14 +03:00
|
|
|
// truncate + pad if needed
|
2019-11-03 16:00:35 +03:00
|
|
|
labelsFmt := text.TruncateMax(labelsTxt.String(), 10)
|
2020-07-13 14:14:47 +03:00
|
|
|
titleFmt := text.LeftPadMaxLine(strings.TrimSpace(b.Title), 50-text.Len(labelsFmt), 0)
|
2019-05-14 18:01:49 +03:00
|
|
|
authorFmt := text.LeftPadMaxLine(name, 15, 0)
|
2018-07-17 21:23:14 +03:00
|
|
|
|
2020-09-27 22:30:13 +03:00
|
|
|
comments := fmt.Sprintf("%3d 💬", b.LenComments-1)
|
|
|
|
if b.LenComments-1 <= 0 {
|
|
|
|
comments = ""
|
|
|
|
}
|
|
|
|
if b.LenComments-1 > 999 {
|
|
|
|
comments = " ∞ 💬"
|
2019-10-28 14:43:24 +03:00
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Printf("%s %s\t%s\t%s\t%s\n",
|
2019-08-12 17:12:14 +03:00
|
|
|
colors.Cyan(b.Id.Human()),
|
2019-02-28 00:19:35 +03:00
|
|
|
colors.Yellow(b.Status),
|
2019-11-03 16:00:35 +03:00
|
|
|
titleFmt+labelsFmt,
|
2018-09-11 23:04:16 +03:00
|
|
|
colors.Magenta(authorFmt),
|
2019-10-28 14:43:24 +03:00
|
|
|
comments,
|
2018-07-17 21:23:14 +03:00
|
|
|
)
|
2018-07-14 23:19:05 +03:00
|
|
|
}
|
2020-06-14 03:41:50 +03:00
|
|
|
return nil
|
|
|
|
}
|
2018-07-14 23:19:05 +03:00
|
|
|
|
2020-06-28 20:09:32 +03:00
|
|
|
func lsPlainFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
|
2020-06-14 03:41:50 +03:00
|
|
|
for _, b := range bugExcerpts {
|
2020-07-13 14:14:47 +03:00
|
|
|
env.out.Printf("%s [%s] %s\n", b.Id.Human(), b.Status, strings.TrimSpace(b.Title))
|
2020-06-14 03:41:50 +03:00
|
|
|
}
|
2018-07-14 23:19:05 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:09:32 +03:00
|
|
|
func lsOrgmodeFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
|
2020-07-14 20:13:46 +03:00
|
|
|
// see https://orgmode.org/manual/Tags.html
|
|
|
|
orgTagRe := regexp.MustCompile("[^[:alpha:]_@]")
|
|
|
|
formatTag := func(l bug.Label) string {
|
|
|
|
return orgTagRe.ReplaceAllString(l.String(), "_")
|
|
|
|
}
|
|
|
|
|
|
|
|
formatTime := func(time time.Time) string {
|
|
|
|
return time.Format("[2006-01-02 Mon 15:05]")
|
|
|
|
}
|
|
|
|
|
2020-07-12 19:53:24 +03:00
|
|
|
env.out.Println("#+TODO: OPEN | CLOSED")
|
2020-06-23 12:51:42 +03:00
|
|
|
|
|
|
|
for _, b := range bugExcerpts {
|
2020-07-12 19:53:24 +03:00
|
|
|
status := strings.ToUpper(b.Status.String())
|
2020-06-23 12:51:42 +03:00
|
|
|
|
|
|
|
var title string
|
|
|
|
if link, ok := b.CreateMetadata["github-url"]; ok {
|
2020-07-12 19:53:24 +03:00
|
|
|
title = fmt.Sprintf("[[%s][%s]]", link, b.Title)
|
2020-06-23 12:51:42 +03:00
|
|
|
} else {
|
|
|
|
title = b.Title
|
|
|
|
}
|
|
|
|
|
|
|
|
var name string
|
|
|
|
if b.AuthorId != "" {
|
2020-06-28 20:09:32 +03:00
|
|
|
author, err := env.backend.ResolveIdentityExcerpt(b.AuthorId)
|
2020-06-23 12:51:42 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
name = author.DisplayName()
|
|
|
|
} else {
|
|
|
|
name = b.LegacyAuthor.DisplayName()
|
|
|
|
}
|
|
|
|
|
2020-07-14 20:13:46 +03:00
|
|
|
var labels strings.Builder
|
|
|
|
labels.WriteString(":")
|
|
|
|
for i, l := range b.Labels {
|
|
|
|
if i > 0 {
|
|
|
|
labels.WriteString(":")
|
2020-07-12 19:53:24 +03:00
|
|
|
}
|
2020-07-14 20:13:46 +03:00
|
|
|
labels.WriteString(formatTag(l))
|
2020-06-23 12:51:42 +03:00
|
|
|
}
|
2020-07-14 20:13:46 +03:00
|
|
|
labels.WriteString(":")
|
2020-06-23 12:51:42 +03:00
|
|
|
|
2020-07-12 19:53:24 +03:00
|
|
|
env.out.Printf("* %-6s %s %s %s: %s %s\n",
|
2020-06-23 12:51:42 +03:00
|
|
|
status,
|
2020-07-12 19:53:24 +03:00
|
|
|
b.Id.Human(),
|
2020-07-14 20:13:46 +03:00
|
|
|
formatTime(b.CreateTime()),
|
2020-06-23 12:51:42 +03:00
|
|
|
name,
|
|
|
|
title,
|
2020-07-14 20:13:46 +03:00
|
|
|
labels.String(),
|
2020-06-23 12:51:42 +03:00
|
|
|
)
|
|
|
|
|
2020-07-14 20:13:46 +03:00
|
|
|
env.out.Printf("** Last Edited: %s\n", formatTime(b.EditTime()))
|
2020-06-23 12:51:42 +03:00
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Printf("** Actors:\n")
|
2020-06-23 12:51:42 +03:00
|
|
|
for _, element := range b.Actors {
|
2020-06-28 20:09:32 +03:00
|
|
|
actor, err := env.backend.ResolveIdentityExcerpt(element)
|
2020-06-23 12:51:42 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Printf(": %s %s\n",
|
2020-06-23 12:51:42 +03:00
|
|
|
actor.Id.Human(),
|
|
|
|
actor.DisplayName(),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Printf("** Participants:\n")
|
2020-06-23 12:51:42 +03:00
|
|
|
for _, element := range b.Participants {
|
2020-06-28 20:09:32 +03:00
|
|
|
participant, err := env.backend.ResolveIdentityExcerpt(element)
|
2020-06-23 12:51:42 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
env.out.Printf(": %s %s\n",
|
2020-06-23 12:51:42 +03:00
|
|
|
participant.Id.Human(),
|
|
|
|
participant.DisplayName(),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-03-22 15:53:34 +03:00
|
|
|
// Finish the command flags transformation into the query.Query
|
2020-06-28 19:26:29 +03:00
|
|
|
func completeQuery(opts *lsOptions) error {
|
|
|
|
for _, str := range opts.statusQuery {
|
2020-03-14 18:47:38 +03:00
|
|
|
status, err := bug.StatusFromString(str)
|
2018-09-10 19:16:16 +03:00
|
|
|
if err != nil {
|
2020-03-22 15:53:34 +03:00
|
|
|
return err
|
2018-09-10 19:16:16 +03:00
|
|
|
}
|
2020-06-28 19:26:29 +03:00
|
|
|
opts.query.Status = append(opts.query.Status, status)
|
2018-09-10 19:16:16 +03:00
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
for _, no := range opts.noQuery {
|
2018-09-10 19:16:16 +03:00
|
|
|
switch no {
|
|
|
|
case "label":
|
2020-06-28 19:26:29 +03:00
|
|
|
opts.query.NoLabel = true
|
2018-09-10 19:16:16 +03:00
|
|
|
default:
|
2020-03-22 15:53:34 +03:00
|
|
|
return fmt.Errorf("unknown \"no\" filter %s", no)
|
2018-09-10 19:16:16 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
switch opts.sortBy {
|
2018-09-10 19:16:16 +03:00
|
|
|
case "id":
|
2020-06-28 19:26:29 +03:00
|
|
|
opts.query.OrderBy = query.OrderById
|
2018-09-10 19:16:16 +03:00
|
|
|
case "creation":
|
2020-06-28 19:26:29 +03:00
|
|
|
opts.query.OrderBy = query.OrderByCreation
|
2018-09-10 19:16:16 +03:00
|
|
|
case "edit":
|
2020-06-28 19:26:29 +03:00
|
|
|
opts.query.OrderBy = query.OrderByEdit
|
2018-09-10 19:16:16 +03:00
|
|
|
default:
|
2020-06-28 19:26:29 +03:00
|
|
|
return fmt.Errorf("unknown sort flag %s", opts.sortBy)
|
2018-09-10 19:16:16 +03:00
|
|
|
}
|
|
|
|
|
2020-06-28 19:26:29 +03:00
|
|
|
switch opts.sortDirection {
|
2018-09-10 19:16:16 +03:00
|
|
|
case "asc":
|
2020-06-28 19:26:29 +03:00
|
|
|
opts.query.OrderDirection = query.OrderAscending
|
2018-09-10 19:16:16 +03:00
|
|
|
case "desc":
|
2020-06-28 19:26:29 +03:00
|
|
|
opts.query.OrderDirection = query.OrderDescending
|
2018-09-10 19:16:16 +03:00
|
|
|
default:
|
2020-06-28 19:26:29 +03:00
|
|
|
return fmt.Errorf("unknown sort direction %s", opts.sortDirection)
|
2018-09-10 19:16:16 +03:00
|
|
|
}
|
|
|
|
|
2020-03-22 15:53:34 +03:00
|
|
|
return nil
|
2018-09-10 19:16:16 +03:00
|
|
|
}
|