cmd/config.go
changeset 10 e4c490882126
parent 0 5abace724584
child 81 b1671f83e91b
--- a/cmd/config.go	Sun Apr 23 15:34:15 2017 +0200
+++ b/cmd/config.go	Sun Apr 23 18:18:51 2017 +0200
@@ -6,6 +6,8 @@
 package cmd
 
 import (
+	"os"
+
 	"github.com/spf13/cobra"
 	"github.com/spf13/viper"
 
@@ -63,9 +65,12 @@
 	if err := madonInitClient(); err != nil {
 		return err
 	}
-	// Try to sign in, but don't mind if it fails
-	if err := madonLogin(); err != nil {
-		errPrint("Info: could not log in: %s", err)
+	// Try to sign in if a login was provided
+	if viper.GetString("token") != "" || viper.GetString("login") != "" {
+		if err := madonLogin(); err != nil {
+			errPrint("Error: could not log in: %s", err)
+			os.Exit(-1)
+		}
 	}
 
 	var p printer.ResourcePrinter