Skip to content

Commit a5293c9

Browse files
Merge pull request #198 from hdresearch/fix/diagnostics-to-stderr
fix(stderr): route diagnostics to stderr, keep stdout for data
2 parents e9ff14c + 26a3dca commit a5293c9

5 files changed

Lines changed: 9 additions & 6 deletions

File tree

internal/handlers/kill.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package handlers
33
import (
44
"context"
55
"fmt"
6+
"os"
67

78
"github.com/hdresearch/vers-cli/internal/app"
89
"github.com/hdresearch/vers-cli/internal/presenters"
@@ -30,7 +31,7 @@ func HandleKill(ctx context.Context, a *app.App, r KillReq) error {
3031
// Confirm if needed
3132
if !r.SkipConfirmation {
3233
for _, t := range targets {
33-
fmt.Printf("Warning: You are about to delete VM '%s'\n", t)
34+
fmt.Fprintf(os.Stderr, "Warning: You are about to delete VM '%s'\n", t)
3435
}
3536
ok, _ := a.Prompter.YesNo("Proceed")
3637
if !ok {

internal/handlers/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func performUpgrade(DebugPrint func(string, ...any), release *update.GitHubRelea
107107
}
108108
fmt.Println("Checksum verification passed")
109109
} else if skipChecksum {
110-
fmt.Println("warning: skipping checksum verification (not recommended)")
110+
fmt.Fprintln(os.Stderr, "warning: skipping checksum verification (not recommended)")
111111
}
112112

113113
currentExe, err := os.Executable()

internal/presenters/branch_presenter.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package presenters
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/hdresearch/vers-cli/internal/app"
78
)
@@ -12,7 +13,7 @@ func RenderBranch(a *app.App, res BranchView) {
1213
newIDs = []string{res.NewID}
1314
}
1415
if len(newIDs) == 0 {
15-
fmt.Println("Error: no VM IDs returned from branch operation")
16+
fmt.Fprintln(os.Stderr, "Error: no VM IDs returned from branch operation")
1617
return
1718
}
1819
numNew := len(newIDs)
@@ -50,7 +51,7 @@ func RenderBranch(a *app.App, res BranchView) {
5051
}
5152

5253
if res.CheckoutErr != nil {
53-
fmt.Printf("WARNING: Failed to update HEAD: %v\n", res.CheckoutErr)
54+
fmt.Fprintf(os.Stderr, "WARNING: Failed to update HEAD: %v\n", res.CheckoutErr)
5455
return
5556
}
5657

internal/presenters/run_presenter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package presenters
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/hdresearch/vers-cli/internal/app"
78
)
@@ -18,6 +19,6 @@ func RenderRun(a *app.App, v RunView) {
1819
if v.HeadTarget != "" {
1920
fmt.Printf("HEAD now points to: %s\n", v.HeadTarget)
2021
} else {
21-
fmt.Println("Warning: .vers directory not found. Run 'vers init' first.")
22+
fmt.Fprintln(os.Stderr, "Warning: .vers directory not found. Run 'vers init' first.")
2223
}
2324
}

internal/runconfig/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func Default() *Config {
5555
func Load() (*Config, error) {
5656
cfg := Default()
5757
if _, err := os.Stat("vers.toml"); os.IsNotExist(err) {
58-
fmt.Println("Warning: vers.toml not found, using default configuration")
58+
fmt.Fprintln(os.Stderr, "Warning: vers.toml not found, using default configuration")
5959
return cfg, nil
6060
}
6161
if _, err := toml.DecodeFile("vers.toml", cfg); err != nil {

0 commit comments

Comments
 (0)