aboutsummaryrefslogtreecommitdiffstats
path: root/commands/ls.go
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-02-14 16:03:51 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-02-21 14:15:50 +0100
commitcb61245078a0e8f14e359ed20e0582a695645a08 (patch)
treeaa0e8f4ea3d8a5eb2f7ac3746875b0854c1714bb /commands/ls.go
parent956f98b676ab44d19ed522061c9520a32aab1a3c (diff)
downloadgit-bug-cb61245078a0e8f14e359ed20e0582a695645a08.tar.gz
Add ability to search by arbitrary metadata
Example: ~/git/git-bug/git-bug ls --metadata github-url=https://github.com/author/myproject/issues/42 or ~/git/git-bug/git-bug ls metadata:github-url:\"https://github.com/author/myproject/issues/42\" Fixes the cmdline part of <https://github.com/MichaelMure/git-bug/issues/567>.
Diffstat (limited to 'commands/ls.go')
-rw-r--r--commands/ls.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/commands/ls.go b/commands/ls.go
index 327fd37f..71c420c6 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -19,6 +19,7 @@ import (
type lsOptions struct {
statusQuery []string
authorQuery []string
+ metadataQuery []string
participantQuery []string
actorQuery []string
labelQuery []string
@@ -65,6 +66,8 @@ git bug ls status:open --by creation "foo bar" baz
"Filter by status. Valid values are [open,closed]")
flags.StringSliceVarP(&options.authorQuery, "author", "a", nil,
"Filter by author")
+ flags.StringSliceVarP(&options.metadataQuery, "metadata", "m", nil,
+ "Filter by metadata. Example: github-url=URL")
flags.StringSliceVarP(&options.participantQuery, "participant", "p", nil,
"Filter by participant")
flags.StringSliceVarP(&options.actorQuery, "actor", "A", nil,
@@ -337,6 +340,16 @@ func completeQuery(q *query.Query, opts lsOptions) error {
}
q.Author = append(q.Author, opts.authorQuery...)
+ for _, str := range opts.metadataQuery {
+ tokens := strings.Split(str, "=")
+ if len(tokens) < 2 {
+ return fmt.Errorf("no \"=\" in key=value metadata markup")
+ }
+ var pair query.StringPair
+ pair.Key = tokens[0]
+ pair.Value = tokens[1]
+ q.Metadata = append(q.Metadata, pair)
+ }
q.Participant = append(q.Participant, opts.participantQuery...)
q.Actor = append(q.Actor, opts.actorQuery...)
q.Label = append(q.Label, opts.labelQuery...)