open: StartWith() and RunWith() revert to default if appName is empty
This commit is contained in:
parent
eef8423979
commit
c533344a20
|
@ -38,6 +38,9 @@ func Start(input string) error {
|
||||||
Wait for the open command to complete.
|
Wait for the open command to complete.
|
||||||
*/
|
*/
|
||||||
func RunWith(input string, appName string) error {
|
func RunWith(input string, appName string) error {
|
||||||
|
if len(appName) == 0 {
|
||||||
|
return Run(input)
|
||||||
|
}
|
||||||
return openWith(input, appName).Run()
|
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.
|
Don't wait for the open command to complete.
|
||||||
*/
|
*/
|
||||||
func StartWith(input string, appName string) error {
|
func StartWith(input string, appName string) error {
|
||||||
|
if len(appName) == 0 {
|
||||||
|
return Start(input)
|
||||||
|
}
|
||||||
return openWith(input, appName).Start()
|
return openWith(input, appName).Start()
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,14 @@ func TestStart(t *testing.T) {
|
||||||
func TestRunWith(t *testing.T) {
|
func TestRunWith(t *testing.T) {
|
||||||
// shouldn't error
|
// shouldn't error
|
||||||
input := "https://google.com/"
|
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"
|
app := "firefox"
|
||||||
err := RunWith(input, app)
|
err = RunWith(input, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("open.RunWith(\"%s\", \"%s\") threw an error: %s", input, app, err)
|
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) {
|
func TestStartWith(t *testing.T) {
|
||||||
// shouldn't error
|
// shouldn't error
|
||||||
input := "https://google.com/"
|
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"
|
app := "firefox"
|
||||||
err := StartWith(input, app)
|
err = StartWith(input, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("open.StartWith(\"%s\", \"%s\") threw an error: %s", input, app, err)
|
t.Errorf("open.StartWith(\"%s\", \"%s\") threw an error: %s", input, app, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue