Skip to content

Commit

Permalink
Merge pull request #14 from theag3nt/use-browser-lib
Browse files Browse the repository at this point in the history
Use external library to open webbrowsers
  • Loading branch information
umutphp committed Oct 30, 2020
2 parents 4af35a1 + 8bc4daa commit 5c2f3ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/manifoldco/promptui v0.7.0
github.com/rhysd/go-github-selfupdate v1.2.2
github.com/toqueteos/webbrowser v1.2.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ github.com/rhysd/go-github-selfupdate v1.2.2 h1:G+mNzkc1wEtpmM6sFS/Ghkeq+ad4Yp6E
github.com/rhysd/go-github-selfupdate v1.2.2/go.mod h1:khesvSyKcXDUxeySCedFh621iawCks0dS/QnHPcpCws=
github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw=
github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE=
github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ=
github.com/toqueteos/webbrowser v1.2.0/go.mod h1:XWoZq4cyp9WeUeak7w7LXRUQf1F1ATJMir8RTqb4ayM=
github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok=
github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
Expand Down
14 changes: 2 additions & 12 deletions internal/package/prompter/prompter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package prompter

import (
"math/rand"
"os/exec"
"runtime"
"strings"
"time"

"github.com/toqueteos/webbrowser"
"github.com/umutphp/awesome-cli/internal/package/fetcher"
"github.com/umutphp/awesome-cli/internal/package/manager"
"github.com/umutphp/awesome-cli/internal/package/node"
Expand Down Expand Up @@ -161,14 +160,5 @@ func PromptToContinue() string {
}

func OpenInBrowser(url string) {
switch runtime.GOOS {
case "linux":
exec.Command("xdg-open", url).Start()
case "windows":
exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
exec.Command("open", url).Start()
default:
// Unsupported platform, nothing to do
}
webbrowser.Open(url)
}

0 comments on commit 5c2f3ef

Please sign in to comment.