use a wrapper for cmd "open" to allow for Linux/Win ports
parent
c0b2fd5f21
commit
48c1aea220
1
go.mod
1
go.mod
|
@ -5,6 +5,7 @@ go 1.19
|
|||
require (
|
||||
fyne.io/systray v1.10.0
|
||||
github.com/rs/zerolog v1.29.0
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
|
||||
github.com/stretchr/testify v1.8.2
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -16,6 +16,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w=
|
||||
github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA=
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/skratchdot/open-golang/open"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
@ -58,10 +60,9 @@ func (w *Wrapper) Cleanup() {
|
|||
func resticCmdFn(args ...string) *exec.Cmd {
|
||||
// Running from GoLand: could be /private/var/folders/5s/csgpcjlx1wg9659_485vqz880000gn/T/GoLand/restictray
|
||||
// Installed: could be /Applications/restictray/restictray.app/Contents/MacOS/restictray
|
||||
// This isn't ideal but I don't want to fiddle with build flags
|
||||
resticExec := filepath.Join(filepath.Dir(executable), "restic")
|
||||
if IsDev() {
|
||||
resticExec = "restic" // dev: assume in $PATH
|
||||
if _, err := os.Stat(resticExec); os.IsNotExist(err) {
|
||||
resticExec = "restic" // can't find embedded exec, assume in $PATH
|
||||
}
|
||||
|
||||
cmd := exec.Command(resticExec, args...)
|
||||
|
@ -90,23 +91,18 @@ func (w *Wrapper) MountBackups(c *Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// OpenConfigFile opens the restic config file using the NON-BLOCKING "open" command.
|
||||
// OpenConfigFile opens the restic config file using the open command.
|
||||
func OpenConfigFile() error {
|
||||
return exec.Command("open", ConfigFile()).Run()
|
||||
return open.Run(ConfigFile())
|
||||
}
|
||||
|
||||
// OpenLogs opens the restic logfile using the NON-BLOCKING "open" command.
|
||||
// OpenLogs opens the restic logfile using the open command.
|
||||
func OpenLogs() error {
|
||||
return exec.Command("open", LogFile()).Run()
|
||||
return open.Run(LogFile())
|
||||
}
|
||||
|
||||
func openFolder(folder string) error {
|
||||
cmd := exec.Command("open", folder)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("open mount dir: %s: %w", string(out), err)
|
||||
}
|
||||
return nil
|
||||
return open.Run(folder)
|
||||
}
|
||||
|
||||
// UpdateLatestSnapshots updates LatestSnapshots or returns an error. If timed out, returns an error as well.
|
||||
|
|
Loading…
Reference in New Issue