From 19c9beb7867d714f003c82591f4cbdebe733f96a Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 21 Nov 2025 02:06:10 +0100 Subject: [PATCH] refactor(print-env): use boolean instead of counter Signed-off-by: Dominik Schmidt --- pkg/app/print_env.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/app/print_env.go b/pkg/app/print_env.go index 10effe19..ecd50270 100644 --- a/pkg/app/print_env.go +++ b/pkg/app/print_env.go @@ -9,7 +9,7 @@ import ( // PrintEnv prints the parsed environment configuration func (a *App) PrintEnv(c PrintEnvConfigProvider) error { - docCount := 0 + firstDoc := true // Open JSON array if needed if c.Output() == "json" { @@ -46,7 +46,7 @@ func (a *App) PrintEnv(c PrintEnvConfigProvider) error { switch c.Output() { case "json": // For JSON, print array of documents - if docCount > 0 { + if !firstDoc { fmt.Println(",") } outputBytes, err = json.MarshalIndent(output, " ", " ") @@ -57,7 +57,7 @@ func (a *App) PrintEnv(c PrintEnvConfigProvider) error { fmt.Print(string(outputBytes)) case "yaml", "": // For YAML, use multi-document format with --- separator - if docCount > 0 { + if !firstDoc { fmt.Println("---") } outputBytes, err = yaml.Marshal(output) @@ -69,7 +69,7 @@ func (a *App) PrintEnv(c PrintEnvConfigProvider) error { return false, []error{fmt.Errorf("unsupported output format: %s (supported: yaml, json)", c.Output())} } - docCount++ + firstDoc = false return false, nil }, false)