diff --git a/cmd/doctor/cmd_doctor.go b/cmd/doctor/cmd_doctor.go index 4aec921d..0b73e2a4 100644 --- a/cmd/doctor/cmd_doctor.go +++ b/cmd/doctor/cmd_doctor.go @@ -2,6 +2,7 @@ package doctor import ( + "errors" "fmt" "forge.lthn.ai/core/cli/pkg/cli" @@ -98,7 +99,7 @@ func runDoctor(verbose bool) error { cli.Error(i18n.T("cmd.doctor.issues", map[string]any{"Count": failed})) fmt.Printf("\n%s\n", i18n.T("cmd.doctor.install_missing")) printInstallInstructions() - return fmt.Errorf("%s", i18n.T("cmd.doctor.issues_error", map[string]any{"Count": failed})) + return errors.New(i18n.T("cmd.doctor.issues_error", map[string]any{"Count": failed})) } cli.Success(i18n.T("cmd.doctor.ready")) diff --git a/cmd/module/cmd_install.go b/cmd/module/cmd_install.go index 0cade6b8..c35d513b 100644 --- a/cmd/module/cmd_install.go +++ b/cmd/module/cmd_install.go @@ -2,7 +2,7 @@ package module import ( "context" - "fmt" + "errors" "forge.lthn.ai/core/cli/pkg/cli" "forge.lthn.ai/core/go/pkg/i18n" @@ -21,7 +21,7 @@ func addInstallCommand(parent *cli.Command) { i18n.T("Install a module by cloning its Git repository, verifying the manifest signature, and registering it.\n\nThe --repo flag is required and specifies the Git URL to clone from."), func(cmd *cli.Command, args []string) error { if installRepo == "" { - return fmt.Errorf("--repo flag is required") + return errors.New("--repo flag is required") } return runInstall(args[0], installRepo, installSignKey) }, diff --git a/cmd/module/cmd_update.go b/cmd/module/cmd_update.go index 4b5fcf3c..c3583af4 100644 --- a/cmd/module/cmd_update.go +++ b/cmd/module/cmd_update.go @@ -2,6 +2,7 @@ package module import ( "context" + "errors" "fmt" "forge.lthn.ai/core/cli/pkg/cli" @@ -20,7 +21,7 @@ func addUpdateCommand(parent *cli.Command) { return runUpdateAll() } if len(args) == 0 { - return fmt.Errorf("module code required (or use --all)") + return errors.New("module code required (or use --all)") } return runUpdate(args[0]) }, diff --git a/cmd/plugin/cmd_update.go b/cmd/plugin/cmd_update.go index 0edcf997..60014b79 100644 --- a/cmd/plugin/cmd_update.go +++ b/cmd/plugin/cmd_update.go @@ -2,6 +2,7 @@ package plugin import ( "context" + "errors" "fmt" "forge.lthn.ai/core/cli/pkg/cli" @@ -22,7 +23,7 @@ func addUpdateCommand(parent *cli.Command) { return runUpdateAll() } if len(args) == 0 { - return fmt.Errorf("plugin name required (or use --all)") + return errors.New("plugin name required (or use --all)") } return runUpdate(args[0]) }, diff --git a/pkg/cli/daemon.go b/pkg/cli/daemon.go index 961bb268..580b83a5 100644 --- a/pkg/cli/daemon.go +++ b/pkg/cli/daemon.go @@ -3,6 +3,7 @@ package cli import ( "context" + "errors" "fmt" "net" "net/http" @@ -309,7 +310,7 @@ func (d *Daemon) Start() error { defer d.mu.Unlock() if d.running { - return fmt.Errorf("daemon already running") + return errors.New("daemon already running") } // Acquire PID file @@ -339,7 +340,7 @@ func (d *Daemon) Run(ctx context.Context) error { d.mu.Lock() if !d.running { d.mu.Unlock() - return fmt.Errorf("daemon not started - call Start() first") + return errors.New("daemon not started - call Start() first") } d.mu.Unlock() diff --git a/pkg/cli/prompt.go b/pkg/cli/prompt.go index d9eb993e..0532901f 100644 --- a/pkg/cli/prompt.go +++ b/pkg/cli/prompt.go @@ -2,6 +2,7 @@ package cli import ( "bufio" + "errors" "fmt" "os" "strconv" @@ -45,7 +46,7 @@ func Select(label string, options []string) (string, error) { n, err := strconv.Atoi(strings.TrimSpace(input)) if err != nil || n < 1 || n > len(options) { - return "", fmt.Errorf("invalid selection") + return "", errors.New("invalid selection") } return options[n-1], nil } diff --git a/pkg/cli/utils.go b/pkg/cli/utils.go index 13d0471a..da84cb3a 100644 --- a/pkg/cli/utils.go +++ b/pkg/cli/utils.go @@ -3,6 +3,7 @@ package cli import ( "bufio" "context" + "errors" "fmt" "os" "os/exec" @@ -474,7 +475,6 @@ func parseMultiSelection(input string, maxItems int) ([]int, error) { return result, nil } - // ChooseMultiAction prompts for multiple selections using grammar composition. // // files := ChooseMultiAction("select", "files", files) @@ -495,14 +495,14 @@ func GitClone(ctx context.Context, org, repo, path string) error { } errStr := strings.TrimSpace(string(output)) if strings.Contains(errStr, "already exists") { - return fmt.Errorf("%s", errStr) + return errors.New(errStr) } } // Fall back to SSH clone cmd := exec.CommandContext(ctx, "git", "clone", fmt.Sprintf("git@github.com:%s/%s.git", org, repo), path) output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("%s", strings.TrimSpace(string(output))) + return errors.New(strings.TrimSpace(string(output))) } return nil }