LoadDefault returns a Registry from the user's tools.yaml when present, or the bundled defaults when not.
()
| 80 | // LoadDefault returns a Registry from the user's tools.yaml when present, or |
| 81 | // the bundled defaults when not. |
| 82 | func LoadDefault() (*Registry, error) { |
| 83 | userPath := filepath.Join(pathutil.ConfigDir(), "tools.yaml") |
| 84 | if pathutil.Exists(userPath) { |
| 85 | data, err := os.ReadFile(userPath) |
| 86 | if err != nil { |
| 87 | return nil, fmt.Errorf("tools: read %s: %w", userPath, err) |
| 88 | } |
| 89 | return parseRegistry(data) |
| 90 | } |
| 91 | return parseRegistry(bundledYAML) |
| 92 | } |
| 93 | |
| 94 | func parseRegistry(data []byte) (*Registry, error) { |
| 95 | var raw struct { |