SEBA-580 Add bash completion;
Add Git Dirty to version;
Add config comamnd
Change-Id: I847dc309a41d74d80e427106bcc839b8db3f9a2c
diff --git a/commands/command.go b/commands/command.go
index 9741e51..6a8d663 100644
--- a/commands/command.go
+++ b/commands/command.go
@@ -111,16 +111,12 @@
Server string `yaml:"server"`
}
-func NewConnection() (*grpc.ClientConn, error) {
+func ProcessGlobalOptions() {
if len(GlobalOptions.Config) == 0 {
- home := os.Getenv("HOME")
- // TODO: Replace after Jenkins updated to go 1.12
- /*
- home, err := os.UserHomeDir()
- if err != nil {
- log.Printf("Unable to discover they users home directory: %s\n", err)
- }
- */
+ home, err := os.UserHomeDir()
+ if err != nil {
+ log.Printf("Unable to discover the users home directory: %s\n", err)
+ }
GlobalOptions.Config = fmt.Sprintf("%s/.cord/config", home)
}
@@ -147,6 +143,19 @@
GlobalConfig.Password = GlobalOptions.Password
}
+ if GlobalConfig.Server == "" {
+ log.Fatal("Server is not set. Please update config file or use the -s option")
+ }
+ if GlobalConfig.Username == "" {
+ log.Fatal("Username is not set. Please update config file or use the -u option")
+ }
+ if GlobalConfig.Password == "" {
+ log.Fatal("Password is not set. Please update config file or use the -p option")
+ }
+}
+
+func NewConnection() (*grpc.ClientConn, error) {
+ ProcessGlobalOptions()
return grpc.Dial(GlobalConfig.Server, grpc.WithInsecure())
}