diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2017-02-20 21:26:21 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-20 21:26:21 +0800 |
commit | 94334c233e5f02324d4427ffe6ffc14d41576e36 (patch) | |
tree | 3887bee78c1910efb5a2d2e8ff77022398636c7a /cmd/internal/browser | |
parent | b7f010de52d267bfd0b5e17f54afeb19b9d5c136 (diff) | |
download | go-tangerine-94334c233e5f02324d4427ffe6ffc14d41576e36.tar go-tangerine-94334c233e5f02324d4427ffe6ffc14d41576e36.tar.gz go-tangerine-94334c233e5f02324d4427ffe6ffc14d41576e36.tar.bz2 go-tangerine-94334c233e5f02324d4427ffe6ffc14d41576e36.tar.lz go-tangerine-94334c233e5f02324d4427ffe6ffc14d41576e36.tar.xz go-tangerine-94334c233e5f02324d4427ffe6ffc14d41576e36.tar.zst go-tangerine-94334c233e5f02324d4427ffe6ffc14d41576e36.zip |
cmd/geth: added 'geth bug' command (#3684)
* cmd/geth: added 'geth bug' command
Added bug command to geth, which will open a browser window
with an issue template and some additional system information.
* cmd/geth: update bug with better infos
* cmd/geth: added browser fallback
* cmd/geth: govet yo momma
Diffstat (limited to 'cmd/internal/browser')
-rw-r--r-- | cmd/internal/browser/browser.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cmd/internal/browser/browser.go b/cmd/internal/browser/browser.go new file mode 100644 index 000000000..897086f47 --- /dev/null +++ b/cmd/internal/browser/browser.go @@ -0,0 +1,46 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package browser provides utilities for interacting with users' browsers. +package browser + +import ( + "os" + "os/exec" + "runtime" +) + +// Commands returns a list of possible commands to use to open a url. +func Commands() [][]string { + var cmds [][]string + if exe := os.Getenv("BROWSER"); exe != "" { + cmds = append(cmds, []string{exe}) + } + switch runtime.GOOS { + case "darwin": + cmds = append(cmds, []string{"/usr/bin/open"}) + case "windows": + cmds = append(cmds, []string{"cmd", "/c", "start"}) + default: + cmds = append(cmds, []string{"xdg-open"}) + } + cmds = append(cmds, + []string{"chrome"}, + []string{"google-chrome"}, + []string{"chromium"}, + []string{"firefox"}, + ) + return cmds +} + +// Open tries to open url in a browser and reports whether it succeeded. +func Open(url string) bool { + for _, args := range Commands() { + cmd := exec.Command(args[0], append(args[1:], url)...) + if cmd.Start() == nil { + return true + } + } + return false +} |