Skip to content

Commit 5c2f3ef

Browse files
authored
Merge pull request #14 from theag3nt/use-browser-lib
Use external library to open webbrowsers
2 parents 4af35a1 + 8bc4daa commit 5c2f3ef

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ require (
66
github.com/blang/semver v3.5.1+incompatible
77
github.com/manifoldco/promptui v0.7.0
88
github.com/rhysd/go-github-selfupdate v1.2.2
9+
github.com/toqueteos/webbrowser v1.2.0
910
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ github.com/rhysd/go-github-selfupdate v1.2.2 h1:G+mNzkc1wEtpmM6sFS/Ghkeq+ad4Yp6E
4242
github.com/rhysd/go-github-selfupdate v1.2.2/go.mod h1:khesvSyKcXDUxeySCedFh621iawCks0dS/QnHPcpCws=
4343
github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw=
4444
github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE=
45+
github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ=
46+
github.com/toqueteos/webbrowser v1.2.0/go.mod h1:XWoZq4cyp9WeUeak7w7LXRUQf1F1ATJMir8RTqb4ayM=
4547
github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
4648
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
4749
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=

internal/package/prompter/prompter.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package prompter
22

33
import (
44
"math/rand"
5-
"os/exec"
6-
"runtime"
75
"strings"
86
"time"
97

8+
"github.com/toqueteos/webbrowser"
109
"github.com/umutphp/awesome-cli/internal/package/fetcher"
1110
"github.com/umutphp/awesome-cli/internal/package/manager"
1211
"github.com/umutphp/awesome-cli/internal/package/node"
@@ -161,14 +160,5 @@ func PromptToContinue() string {
161160
}
162161

163162
func OpenInBrowser(url string) {
164-
switch runtime.GOOS {
165-
case "linux":
166-
exec.Command("xdg-open", url).Start()
167-
case "windows":
168-
exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
169-
case "darwin":
170-
exec.Command("open", url).Start()
171-
default:
172-
// Unsupported platform, nothing to do
173-
}
163+
webbrowser.Open(url)
174164
}

0 commit comments

Comments
 (0)