feat(print-env): add output format validation

Signed-off-by: Dominik Schmidt <dev@dominik-schmidt.de>
This commit is contained in:
Dominik Schmidt 2025-11-21 01:57:57 +01:00
parent adf0b94dda
commit eb104ce5c8
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package config
import "fmt"
// PrintEnvOptions is the options for the print-env command
type PrintEnvOptions struct {
// Output is the output format (yaml or json)
@ -31,3 +33,11 @@ func NewPrintEnvImpl(g *GlobalImpl, p *PrintEnvOptions) *PrintEnvImpl {
func (c *PrintEnvImpl) Output() string {
return c.PrintEnvOptions.Output
}
// ValidateConfig validates the print-env configuration
func (c *PrintEnvImpl) ValidateConfig() error {
if c.PrintEnvOptions.Output != "yaml" && c.PrintEnvOptions.Output != "json" {
return fmt.Errorf("invalid output format %q: must be 'yaml' or 'json'", c.PrintEnvOptions.Output)
}
return nil
}