Set exit code to non-zero when API calls fail
(This doesn't cover all calls yet.)
--- a/cmd/accounts.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/accounts.go Sun Apr 30 23:35:49 2017 +0200
@@ -530,7 +530,7 @@
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
if obj == nil {
return nil
--- a/cmd/instance.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/instance.go Sun Apr 30 23:35:49 2017 +0200
@@ -65,7 +65,7 @@
i, err := gClient.GetCurrentInstance()
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
p, err := getPrinter()
--- a/cmd/media.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/media.go Sun Apr 30 23:35:49 2017 +0200
@@ -6,6 +6,8 @@
package cmd
import (
+ "os"
+
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -44,7 +46,7 @@
attachment, err := gClient.UploadMedia(opt.filePath)
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
p, err := getPrinter()
--- a/cmd/notifications.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/notifications.go Sun Apr 30 23:35:49 2017 +0200
@@ -6,6 +6,8 @@
package cmd
import (
+ "os"
+
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -90,7 +92,7 @@
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
if obj == nil {
return nil
--- a/cmd/search.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/search.go Sun Apr 30 23:35:49 2017 +0200
@@ -6,6 +6,7 @@
package cmd
import (
+ "os"
"strings"
"github.com/pkg/errors"
@@ -46,7 +47,7 @@
results, err := gClient.Search(strings.Join(args, " "), opt.resolve)
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
p, err := getPrinter()
--- a/cmd/status.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/status.go Sun Apr 30 23:35:49 2017 +0200
@@ -7,6 +7,7 @@
import (
"io/ioutil"
+ "os"
"strings"
"github.com/pkg/errors"
@@ -251,7 +252,7 @@
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
if obj == nil {
return nil
--- a/cmd/stream.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/stream.go Sun Apr 30 23:35:49 2017 +0200
@@ -7,6 +7,7 @@
import (
"io"
+ "os"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -84,7 +85,7 @@
err := gClient.StreamListener(streamName, tag, evChan, stop, done)
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
p, err := getPrinter()
--- a/cmd/timelines.go Sun Apr 30 23:22:09 2017 +0200
+++ b/cmd/timelines.go Sun Apr 30 23:35:49 2017 +0200
@@ -6,6 +6,8 @@
package cmd
import (
+ "os"
+
"github.com/spf13/cobra"
"github.com/McKael/madon"
@@ -73,7 +75,7 @@
sl, err := gClient.GetTimelines(tl, opt.local, limOpts)
if err != nil {
errPrint("Error: %s", err.Error())
- return nil
+ os.Exit(1)
}
if opt.limit > 0 && len(sl) > int(opt.limit) {