LoadDefaultProject reads the default_project key from the global config. Returns empty string if not set or if the config file doesn't exist.
()
| 61 | // LoadDefaultProject reads the default_project key from the global config. |
| 62 | // Returns empty string if not set or if the config file doesn't exist. |
| 63 | func LoadDefaultProject() string { |
| 64 | cfgPath, err := globalConfigPath() |
| 65 | if err != nil { |
| 66 | return "" |
| 67 | } |
| 68 | |
| 69 | data, err := os.ReadFile(cfgPath) |
| 70 | if err != nil { |
| 71 | return "" |
| 72 | } |
| 73 | |
| 74 | var cfg globalConfig |
| 75 | if err := yaml.Unmarshal(data, &cfg); err != nil { |
| 76 | return "" |
| 77 | } |
| 78 | |
| 79 | return cfg.DefaultProject |
| 80 | } |
| 81 | |
| 82 | // parseProjectEntries converts raw YAML entries into validated GlobalProjectEntry values. |
| 83 | func parseProjectEntries(projects []globalProjectYAML, cfgDir string) ([]GlobalProjectEntry, error) { |