diff options
author | Michael Muré <batolettre@gmail.com> | 2021-03-07 21:46:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-07 21:46:55 +0100 |
commit | 2a21b02af157275e20c4ce6d308b45f9a3d7ebaf (patch) | |
tree | e8706dfe1679dd2dcb4524ef0473a6d0fa4f4227 /commands | |
parent | 87bc42fb4695872b82cfa9a922d423df7ff21132 (diff) | |
parent | 3a819525d7811dcfb01d928af0e243de4388c456 (diff) | |
download | git-bug-2a21b02af157275e20c4ce6d308b45f9a3d7ebaf.tar.gz |
Merge pull request #593 from vmiklos/webui-query
webui: allow specifying the initial query
Diffstat (limited to 'commands')
-rw-r--r-- | commands/webui.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/commands/webui.go b/commands/webui.go index d910a703..2f80bcd0 100644 --- a/commands/webui.go +++ b/commands/webui.go @@ -6,6 +6,7 @@ import ( "log" "net" "net/http" + "net/url" "os" "os/signal" "strconv" @@ -34,6 +35,7 @@ type webUIOptions struct { open bool noOpen bool readOnly bool + query string } func newWebUICommand() *cobra.Command { @@ -62,6 +64,7 @@ Available git config: 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 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 } @@ -77,6 +80,12 @@ func runWebUI(env *Env, opts webUIOptions, args []string) error { 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() @@ -154,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) } |