From 949781fa0a5f0654112b4f78558347ca991a89d3 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sat, 30 Jan 2021 11:33:31 +0100 Subject: Refactor lib/open to accept user provided arguments * Get rid of open_darwin It just lead to code duplication for a simple one string change. Instead we query it during initialization * Accept user provided arguments "open" on MacOS accepts things like -A to use a specific application Pass trough arguments the user provided in order to facilitate this * Refactor the function to a struct This makes it more convenient for the caller and avoids signatures like lib.OpenFile(nil, u.String(), nil) which are fairly unreadable --- lib/open_darwin.go | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 lib/open_darwin.go (limited to 'lib/open_darwin.go') diff --git a/lib/open_darwin.go b/lib/open_darwin.go deleted file mode 100644 index d98c8988..00000000 --- a/lib/open_darwin.go +++ /dev/null @@ -1,21 +0,0 @@ -package lib - -import ( - "os/exec" -) - -func OpenFile(filename string, onErr func(error)) { - cmd := exec.Command("open", filename) - err := cmd.Start() - if err != nil && onErr != nil { - onErr(err) - return - } - - go func() { - err := cmd.Wait() - if err != nil && onErr != nil { - onErr(err) - } - }() -} -- cgit