diff --git a/open/open.go b/open/open.go index b1f648f..02361ce 100644 --- a/open/open.go +++ b/open/open.go @@ -38,6 +38,9 @@ func Start(input string) error { Wait for the open command to complete. */ func RunWith(input string, appName string) error { + if len(appName) == 0 { + return Run(input) + } return openWith(input, appName).Run() } @@ -46,5 +49,8 @@ func RunWith(input string, appName string) error { Don't wait for the open command to complete. */ func StartWith(input string, appName string) error { + if len(appName) == 0 { + return Start(input) + } return openWith(input, appName).Start() } diff --git a/open/open_test.go b/open/open_test.go index 5db2da2..f1a043c 100644 --- a/open/open_test.go +++ b/open/open_test.go @@ -37,8 +37,14 @@ func TestStart(t *testing.T) { func TestRunWith(t *testing.T) { // shouldn't error input := "https://google.com/" + err := RunWith(input, "") + if err != nil { + t.Errorf("open.RunWith(\"%s\", \"\") threw an error: %s", input, err) + } + + // shouldn't error app := "firefox" - err := RunWith(input, app) + err = RunWith(input, app) if err != nil { t.Errorf("open.RunWith(\"%s\", \"%s\") threw an error: %s", input, app, err) } @@ -54,8 +60,14 @@ func TestRunWith(t *testing.T) { func TestStartWith(t *testing.T) { // shouldn't error input := "https://google.com/" + err := StartWith(input, "") + if err != nil { + t.Errorf("open.StartWith(\"%s\", \"\") threw an error: %s", input, err) + } + + // shouldn't error app := "firefox" - err := StartWith(input, app) + err = StartWith(input, app) if err != nil { t.Errorf("open.StartWith(\"%s\", \"%s\") threw an error: %s", input, app, err) }