MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / runConfigShow

Function runConfigShow

cmd/lambda-nat-proxy/cmd_config.go:151–180  ·  view source on GitHub ↗

runConfigShow implements the config show command

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

149
150// runConfigShow implements the config show command
151func 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
183func getConfigSource(configPath string) string {

Callers 1

cmd_config.goFile · 0.85

Calls 2

LoadCLIConfigFunction · 0.92
getConfigSourceFunction · 0.85

Tested by

no test coverage detected