refactor: return errors from NewCLIInstance instead of panicking

Change NewCLIInstance() and NewCLIInstanceWithFs() to return
(*Instance, error) instead of panicking on DetermineStateDir failure.

Callers in RunE contexts propagate the error. Callers in command
construction (for shell completion) use log.Fatalf. Test callers
use t.Fatalf.

Addresses review feedback on PR #18.
Цей коміт міститься в:
clawbot
2026-02-19 23:53:35 -08:00
джерело 36ece2fca7
коміт 6be4601763
12 змінених файлів з 156 додано та 42 видалено
+5 -1
Переглянути файл
@@ -1,6 +1,7 @@
package cli
import (
"log"
"encoding/json"
"fmt"
"io"
@@ -40,7 +41,10 @@ type InfoOutput struct {
// newInfoCmd returns the info command
func newInfoCmd() *cobra.Command {
cli := NewCLIInstance()
cli, err := NewCLIInstance()
if err != nil {
log.Fatalf("failed to initialize CLI: %v", err)
}
var jsonOutput bool