Helper function for read-only config operations
(cmd *cobra.Command, fn func(*environment.EnvironmentConfig) error)
| 14 | |
| 15 | // Helper function for read-only config operations |
| 16 | func withConfig(cmd *cobra.Command, fn func(*environment.EnvironmentConfig) error) error { |
| 17 | ctx := cmd.Context() |
| 18 | repo, err := repository.Open(ctx, ".") |
| 19 | if err != nil { |
| 20 | return fmt.Errorf("failed to open repository: %w", err) |
| 21 | } |
| 22 | |
| 23 | config := environment.DefaultConfig() |
| 24 | if err := config.Load(repo.SourcePath()); err != nil { |
| 25 | return fmt.Errorf("failed to load configuration: %w", err) |
| 26 | } |
| 27 | |
| 28 | return fn(config) |
| 29 | } |
| 30 | |
| 31 | // Helper function for config update operations |
| 32 | func updateConfig(cmd *cobra.Command, fn func(*environment.EnvironmentConfig) error) error { |
no test coverage detected