runConfigShow implements the config show command
(cmd *cobra.Command)
| 149 | |
| 150 | // runConfigShow implements the config show command |
| 151 | func runConfigShow(cmd *cobra.Command) error { |
| 152 | // Load configuration |
| 153 | configPath, _ := cmd.Flags().GetString("config") |
| 154 | cfg, err := config.LoadCLIConfig(configPath) |
| 155 | if err != nil { |
| 156 | return fmt.Errorf("failed to load configuration: %w", err) |
| 157 | } |
| 158 | |
| 159 | // Show config source information |
| 160 | configSource := getConfigSource(configPath) |
| 161 | fmt.Printf("# Configuration loaded from: %s\n\n", configSource) |
| 162 | |
| 163 | format, _ := cmd.Flags().GetString("format") |
| 164 | |
| 165 | switch format { |
| 166 | case "yaml": |
| 167 | encoder := yaml.NewEncoder(os.Stdout) |
| 168 | encoder.SetIndent(2) |
| 169 | defer encoder.Close() |
| 170 | return encoder.Encode(cfg) |
| 171 | case "json": |
| 172 | // Could implement JSON output here |
| 173 | return fmt.Errorf("JSON format not yet implemented") |
| 174 | case "table": |
| 175 | // Could implement table format here |
| 176 | return fmt.Errorf("table format not yet implemented") |
| 177 | default: |
| 178 | return fmt.Errorf("unsupported format: %s", format) |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // getConfigSource returns a user-friendly description of where config is loaded from |
| 183 | func getConfigSource(configPath string) string { |
no test coverage detected