Skip to content

Commit

Permalink
mrege in master
Browse files Browse the repository at this point in the history
  • Loading branch information
rickschubert committed Mar 2, 2021
2 parents 3d83103 + 7232d62 commit d3c3ca1
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os/exec"
"runtime"

"github.com/Songmu/prompter"
"github.com/atotto/clipboard"
Expand All @@ -15,9 +16,25 @@ import (
)

func openLinkInBrowser(link string) {
color.Green(fmt.Sprintf("Your new ticket has been successfully created! The link is %s \nWe will now try to open the new ticket for you in the browser. (Probably doesn't work on Windows.)", link))
cmd := exec.Command("open", link)
cmd.Run()
color.Green(fmt.Sprintf("Your new ticket has been successfully created! The link is %s \nWe will now try to open the new ticket for you in the browser.", link))
os := runtime.GOOS
switch os {
case "windows":
cmd := exec.Command("start", link)
cmd.Run()
case "darwin":
cmd := exec.Command("open", link)
cmd.Run()
case "linux":
_, err := exec.Command("which xdg-open").Output()
if err != nil {
color.Red(fmt.Sprintf("Unable to open link, please install xdg-open."))
}
cmd := exec.Command("xdg-open", link)
cmd.Run()
default:
color.Red(fmt.Sprintf("Unable to open link for unsupported OS '%s'.\n", os))
}
}

func getClipboardContent() string {
Expand Down

0 comments on commit d3c3ca1

Please sign in to comment.