From 7a555d2bcf32df453089d2523f949d90eb0169c7 Mon Sep 17 00:00:00 2001 From: olgeni Date: Mon, 1 Dec 2025 21:35:42 +0100 Subject: [PATCH] Replace panic with os.Exit(1) for cleaner CLI error handling. Cobra already prints the error message for unknown commands, so panicking is redundant and produces an ugly stacktrace. Now the program exits gracefully with a non-zero exit code. --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 65a2906..b47aab8 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,13 @@ package main import ( + "os" + "github.com/ksred/ccswitch/cmd" ) func main() { if err := cmd.Execute(); err != nil { - panic(err) + os.Exit(1) } }