for idx, a := range os.Args[1:] {
// Specific case to print help or version of xds-gdb
switch a {
- case "--help", "-h", "--version", "-v":
+ case "--help", "-h", "--version", "-v", "--list", "-ls":
args[1] = a
goto endloop
case "--":
// Source config env file
// (we cannot use confFile var because env variables setting is just after)
envMap, confFile, err := loadConfigEnvFile(os.Getenv("XDS_CONFIG"), gdbCmdFile)
+ log.Infof("Load env config: envMap=%v, confFile=%v, err=%v", envMap, confFile, err)
// Only rise an error when args is not set (IOW when --help or --version is not set)
if len(args) == 1 {
var err error
curDir, _ := os.Getwd()
+ // Build env variables
+ env := []string{}
+ for k, v := range envMap {
+ env = append(env, k+"="+v)
+ }
+
// Now set logger level and log file to correct/env var settings
if log.Level, err = logrus.ParseLevel(logLevel); err != nil {
msg := fmt.Sprintf("Invalid log level : \"%v\"\n", logLevel)
log.Out = fdL
}
- // Build env variables
- env := []string{}
- for k, v := range envMap {
- env = append(env, k+"="+v)
- }
-
// Create cross or native gdb interface
var gdb IGDB
if gdbNative != "" {
defer os.Remove(confFile)
}
if err != nil {
- return envMap, confFile, fmt.Errorf(err.Error())
+ log.Infof("Extraction from gdbCmdFile failed: %v", err.Error())
}
}
// 2- search xds-gdb.env file in various locations
xdsEnvFile := "xds-gdb.env"
for _, d := range []string{
path.Join(curDir),
- path.Join(curDir, "..", ".."),
- path.Join(curDir, "../../target"),
- path.Join(u.HomeDir, ".xds"),
+ path.Join(curDir, ".."),
+ path.Join(curDir, "target"),
+ path.Join(u.HomeDir, ".config", "xds"),
} {
confFile = path.Join(d, xdsEnvFile)
log.Infof("Search config in %s", confFile)
return envMap, "", nil
}
- log.Infof("Use conf file: %s", confFile)
if !common.Exists(confFile) {
return envMap, confFile, fmt.Errorf("Error no env config file not found")
}
if envMap, err = godotenv.Read(confFile); err != nil {
return envMap, confFile, fmt.Errorf("Error reading env config file " + confFile)
}
+
return envMap, confFile, nil
}