Merge pull request 'chore: Go 1.26 modernization' (#7) from chore/go-1.26-modernization into main
This commit is contained in:
commit
4dfbddf11f
11 changed files with 26 additions and 29 deletions
|
|
@ -2,6 +2,7 @@
|
|||
package doctor
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"forge.lthn.ai/core/cli/pkg/cli"
|
||||
|
|
@ -95,10 +96,10 @@ func runDoctor(verbose bool) error {
|
|||
// Summary
|
||||
fmt.Println()
|
||||
if failed > 0 {
|
||||
cli.Error(i18n.T("cmd.doctor.issues", map[string]interface{}{"Count": failed}))
|
||||
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]interface{}{"Count": failed}))
|
||||
return errors.New(i18n.T("cmd.doctor.issues_error", map[string]any{"Count": failed}))
|
||||
}
|
||||
|
||||
cli.Success(i18n.T("cmd.doctor.ready"))
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func checkGitHubCLI() bool {
|
|||
func checkWorkspace() {
|
||||
registryPath, err := repos.FindRegistry(io.Local)
|
||||
if err == nil {
|
||||
fmt.Printf(" %s %s\n", successStyle.Render("✓"), i18n.T("cmd.doctor.repos_yaml_found", map[string]interface{}{"Path": registryPath}))
|
||||
fmt.Printf(" %s %s\n", successStyle.Render("✓"), i18n.T("cmd.doctor.repos_yaml_found", map[string]any{"Path": registryPath}))
|
||||
|
||||
reg, err := repos.LoadRegistry(io.Local, registryPath)
|
||||
if err == nil {
|
||||
|
|
@ -71,7 +71,7 @@ func checkWorkspace() {
|
|||
cloned++
|
||||
}
|
||||
}
|
||||
fmt.Printf(" %s %s\n", successStyle.Render("✓"), i18n.T("cmd.doctor.repos_cloned", map[string]interface{}{"Cloned": cloned, "Total": len(allRepos)}))
|
||||
fmt.Printf(" %s %s\n", successStyle.Render("✓"), i18n.T("cmd.doctor.repos_cloned", map[string]any{"Cloned": cloned, "Total": len(allRepos)}))
|
||||
}
|
||||
} else {
|
||||
fmt.Printf(" %s %s\n", dimStyle.Render("○"), i18n.T("cmd.doctor.no_repos_yaml"))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package pkgcmd
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -147,8 +148,8 @@ func runPkgSearch(org, pattern, repoType string, limit int, refresh bool) error
|
|||
return nil
|
||||
}
|
||||
|
||||
sort.Slice(filtered, func(i, j int) bool {
|
||||
return filtered[i].Name < filtered[j].Name
|
||||
slices.SortFunc(filtered, func(a, b ghRepo) int {
|
||||
return cmp.Compare(a.Name, b.Name)
|
||||
})
|
||||
|
||||
fmt.Print(i18n.T("cmd.pkg.search.found_repos", map[string]int{"Count": len(filtered)}) + "\n\n")
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -266,10 +266,7 @@ func (f *Frame) viewLocked() string {
|
|||
footerH = 1
|
||||
}
|
||||
}
|
||||
middleH := h - headerH - footerH
|
||||
if middleH < 1 {
|
||||
middleH = 1
|
||||
}
|
||||
middleH := max(h-headerH-footerH, 1)
|
||||
|
||||
// Render each region
|
||||
header := f.renderRegionLocked(RegionHeader, w, headerH)
|
||||
|
|
@ -287,10 +284,7 @@ func (f *Frame) viewLocked() string {
|
|||
rightW = w / 4
|
||||
}
|
||||
}
|
||||
contentW := w - leftW - rightW
|
||||
if contentW < 1 {
|
||||
contentW = 1
|
||||
}
|
||||
contentW := max(w-leftW-rightW, 1)
|
||||
|
||||
left := f.renderRegionLocked(RegionLeft, leftW, middleH)
|
||||
right := f.renderRegionLocked(RegionRight, rightW, middleH)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,10 +288,7 @@ func (t *Table) constrainWidths(widths []int) {
|
|||
}
|
||||
|
||||
// Shrink widest columns first until we fit.
|
||||
budget := t.maxWidth - overhead
|
||||
if budget < cols {
|
||||
budget = cols
|
||||
}
|
||||
budget := max(t.maxWidth-overhead, cols)
|
||||
for total-overhead > budget {
|
||||
maxIdx, maxW := 0, 0
|
||||
for i, w := range widths {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue