From 9ae5d8fa67df21c108f15154b802c1772abe9a2e Mon Sep 17 00:00:00 2001 From: hhio618 Date: Thu, 13 Sep 2018 22:11:27 +0430 Subject: [PATCH] login CRLF fix --- cmd/auth.go | 6 +++--- config/config.go | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/auth.go b/cmd/auth.go index 7c8669c..b3c3922 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -33,15 +33,15 @@ func login(cmd *cobra.Command, args []string) { req := &uvApi.LoginReq{Email: email, Password: password} res, err := client.V1().Login(client.Context(), req) if err != nil { - log.Fatalf("Could not Login: %v", err) + log.Fatalf("\r\nCould not Login: %v", err) } - log.Printf("Login successful!") + log.Printf("\r\nLogin successful!") viper.Set(config.KEY_TOKEN, res.Token) // Save TOKEN to config file if err = config.ResetConfigFile(); err != nil { - log.Fatalf("Could not Save ConfigFile: %v", err) + log.Fatalf("\r\nCould not Save ConfigFile: %v", err) } } diff --git a/config/config.go b/config/config.go index a8ed0ed..2145853 100644 --- a/config/config.go +++ b/config/config.go @@ -21,7 +21,7 @@ const ( ) var ( - // Get config file Path from the flag. + //ConfigManualAddress Get config file Path from the flag. ConfigManualAddress = "" // Find home directory for definition of archive folder @@ -44,6 +44,7 @@ func isJSON(in []byte) bool { } +//ensureConfigFile Ensure that a valid config file exists func ensureConfigFile(filename string) { var err error var f *os.File @@ -76,6 +77,7 @@ func ensureConfigFile(filename string) { } } +//UpdateVarByConfigFile read config file into viper func UpdateVarByConfigFile() { // read config either from Flag --config or Path "$HOME/.uv/config.json" var filename string @@ -94,6 +96,7 @@ func UpdateVarByConfigFile() { } } +//ResetConfigFile wipes config file func ResetConfigFile() (err error) { return viper.WriteConfig() }