From dd0823dd2ba68a9c778e81b26e53600b159b5a7d Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 9 Sep 2018 20:22:46 +0200 Subject: ls: accept a query to sort and filter the list --- commands/ls.go | 14 ++++++++++++-- doc/man/git-bug-ls.1 | 2 +- doc/md/git-bug_ls.md | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/commands/ls.go b/commands/ls.go index 18496e06..339f1469 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -16,7 +16,17 @@ func runLsBug(cmd *cobra.Command, args []string) error { } defer backend.Close() - allIds := backend.AllBugsId(cache.OrderByCreation, cache.OrderAscending) + var query *cache.Query + if len(args) >= 1 { + fmt.Println("Query", args[0]) + query, err = cache.ParseQuery(args[0]) + + if err != nil { + return err + } + } + + allIds := backend.QueryBugs(query) for _, id := range allIds { b, err := backend.ResolveBug(id) @@ -50,7 +60,7 @@ func runLsBug(cmd *cobra.Command, args []string) error { } var lsCmd = &cobra.Command{ - Use: "ls", + Use: "ls ", Short: "Display a summary of all bugs", RunE: runLsBug, } diff --git a/doc/man/git-bug-ls.1 b/doc/man/git-bug-ls.1 index 00622f4f..2f54503f 100644 --- a/doc/man/git-bug-ls.1 +++ b/doc/man/git-bug-ls.1 @@ -10,7 +10,7 @@ git\-bug\-ls \- Display a summary of all bugs .SH SYNOPSIS .PP -\fBgit\-bug ls [flags]\fP +\fBgit\-bug ls [flags]\fP .SH DESCRIPTION diff --git a/doc/md/git-bug_ls.md b/doc/md/git-bug_ls.md index b7e2da56..5b89fabb 100644 --- a/doc/md/git-bug_ls.md +++ b/doc/md/git-bug_ls.md @@ -7,7 +7,7 @@ Display a summary of all bugs Display a summary of all bugs ``` -git-bug ls [flags] +git-bug ls [flags] ``` ### Options -- cgit