From c533344a2052b4d09df9cf26408fdde9b71caac2 Mon Sep 17 00:00:00 2001 From: technoweenie Date: Fri, 21 Feb 2020 07:25:01 -0700 Subject: [PATCH] open: StartWith() and RunWith() revert to default if appName is empty --- open/open.go | 6 ++++++ open/open_test.go | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) 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) }