url.go 594 B

12345678910111213141516171819202122232425262728293031
  1. package engine
  2. import (
  3. "os/exec"
  4. "strings"
  5. log "github.com/sirupsen/logrus"
  6. )
  7. // OpenURL tries to open an URL with the system browser
  8. func (ac *Config) OpenURL(host, cPort string, httpsPrefix bool) {
  9. // Build the URL
  10. var sb strings.Builder
  11. if httpsPrefix {
  12. sb.WriteString("https://")
  13. } else {
  14. sb.WriteString("http://")
  15. }
  16. if host == "" {
  17. sb.WriteString("localhost")
  18. } else {
  19. sb.WriteString(host)
  20. }
  21. sb.WriteString(cPort)
  22. url := sb.String()
  23. // Open the URL
  24. log.Info("Running: " + ac.openExecutable + " " + url)
  25. cmd := exec.Command(ac.openExecutable, url)
  26. cmd.Run()
  27. }