1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'openutilupdate' of github.com:Seanstoppable/wtf into Seanstoppable-openutilupdate

This commit is contained in:
Chris Cummer
2019-10-15 15:27:56 -04:00
4 changed files with 13 additions and 2 deletions

View File

@@ -2,8 +2,10 @@ package utils
// OpenFileUtil defines the system utility to use to open files
var OpenFileUtil = "open"
var OpenUrlUtil = []string{}
// Init initializes global settings in the wtf package
func Init(openFileUtil string) {
func Init(openFileUtil string, openUrlUtil []string) {
OpenFileUtil = openFileUtil
OpenUrlUtil = openUrlUtil
}

View File

@@ -87,6 +87,12 @@ func Includes(strs []string, val string) bool {
// OpenFile opens the file defined in `path` via the operating system
func OpenFile(path string) {
if (strings.HasPrefix(path, "http://")) || (strings.HasPrefix(path, "https://")) {
if len(OpenUrlUtil) > 0 {
commands := append(OpenUrlUtil, path)
args := commands[1:len(commands)]
exec.Command(commands[0], args...).Start()
return
}
switch runtime.GOOS {
case "linux":
exec.Command("xdg-open", path).Start()