aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/ls.go13
-rw-r--r--commands/webui.go19
2 files changed, 29 insertions, 3 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...)
diff --git a/commands/webui.go b/commands/webui.go
index 7e5fc752..2f80bcd0 100644
--- a/commands/webui.go
+++ b/commands/webui.go
@@ -4,9 +4,12 @@ import (
"context"
"fmt"
"log"
+ "net"
"net/http"
+ "net/url"
"os"
"os/signal"
+ "strconv"
"time"
"github.com/99designs/gqlgen/graphql/playground"
@@ -27,10 +30,12 @@ import (
const webUIOpenConfigKey = "git-bug.webui.open"
type webUIOptions struct {
+ host string
port int
open bool
noOpen bool
readOnly bool
+ query string
}
func newWebUICommand() *cobra.Command {
@@ -54,10 +59,12 @@ Available git config:
flags := cmd.Flags()
flags.SortFlags = false
+ flags.StringVar(&options.host, "host", "127.0.0.1", "Network address or hostname to listen to (default to 127.0.0.1)")
flags.BoolVar(&options.open, "open", false, "Automatically open the web UI in the default browser")
flags.BoolVar(&options.noOpen, "no-open", false, "Prevent the automatic opening of the web UI in the default browser")
- flags.IntVarP(&options.port, "port", "p", 0, "Port to listen to (default is random)")
+ flags.IntVarP(&options.port, "port", "p", 0, "Port to listen to (default to random available port)")
flags.BoolVar(&options.readOnly, "read-only", false, "Whether to run the web UI in read-only mode")
+ flags.StringVarP(&options.query, "query", "q", "", "The query to open in the web UI bug list")
return cmd
}
@@ -71,8 +78,14 @@ func runWebUI(env *Env, opts webUIOptions, args []string) error {
}
}
- addr := fmt.Sprintf("127.0.0.1:%d", opts.port)
+ addr := net.JoinHostPort(opts.host, strconv.Itoa(opts.port))
webUiAddr := fmt.Sprintf("http://%s", addr)
+ toOpen := webUiAddr
+
+ if len(opts.query) > 0 {
+ // Explicitly set the query parameter instead of going with a default one.
+ toOpen = fmt.Sprintf("%s/?q=%s", webUiAddr, url.QueryEscape(opts.query))
+ }
router := mux.NewRouter()
@@ -150,7 +163,7 @@ func runWebUI(env *Env, opts webUIOptions, args []string) error {
shouldOpen := (configOpen && !opts.noOpen) || opts.open
if shouldOpen {
- err = open.Run(webUiAddr)
+ err = open.Run(toOpen)
if err != nil {
env.out.Println(err)
}