aboutsummaryrefslogtreecommitdiffstats
path: root/commands/webui.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-03-07 21:44:48 +0100
committerMichael Muré <batolettre@gmail.com>2021-03-07 21:44:48 +0100
commit3a819525d7811dcfb01d928af0e243de4388c456 (patch)
treee8706dfe1679dd2dcb4524ef0473a6d0fa4f4227 /commands/webui.go
parent626ec9835b4450fb2994ec931357279700437b6b (diff)
downloadgit-bug-3a819525d7811dcfb01d928af0e243de4388c456.tar.gz
commands: minor fixes for the webui open with query
- go fmt - add a shorthand - fix displayed webUI URL in the terminal
Diffstat (limited to 'commands/webui.go')
-rw-r--r--commands/webui.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/commands/webui.go b/commands/webui.go
index 3857e968..2f80bcd0 100644
--- a/commands/webui.go
+++ b/commands/webui.go
@@ -35,7 +35,7 @@ type webUIOptions struct {
open bool
noOpen bool
readOnly bool
- query string
+ query string
}
func newWebUICommand() *cobra.Command {
@@ -64,7 +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.StringVar(&options.query, "query", "", "Set a custom query")
+ flags.StringVarP(&options.query, "query", "q", "", "The query to open in the web UI bug list")
return cmd
}
@@ -80,10 +80,11 @@ 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.
- webUiAddr = fmt.Sprintf("%s/?q=%s", webUiAddr, url.QueryEscape(opts.query))
+ toOpen = fmt.Sprintf("%s/?q=%s", webUiAddr, url.QueryEscape(opts.query))
}
router := mux.NewRouter()
@@ -162,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)
}