Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ...' (#21) from agent/update-the-code-against-the-ax-design-pr into dev
All checks were successful
Security Scan / security (push) Successful in 16s

This commit is contained in:
Virgil 2026-03-31 19:54:54 +00:00
commit ab3045e451
2 changed files with 36 additions and 4 deletions

View file

@ -34,16 +34,14 @@ func addPkgSearchCommand(parent *cobra.Command) {
Use: "search", Use: "search",
Short: i18n.T("cmd.pkg.search.short"), Short: i18n.T("cmd.pkg.search.short"),
Long: i18n.T("cmd.pkg.search.long"), Long: i18n.T("cmd.pkg.search.long"),
Args: cobra.RangeArgs(0, 1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
org := searchOrg org := searchOrg
pattern := searchPattern pattern := resolvePkgSearchPattern(searchPattern, args)
limit := searchLimit limit := searchLimit
if org == "" { if org == "" {
org = "host-uk" org = "host-uk"
} }
if pattern == "" {
pattern = "*"
}
if limit == 0 { if limit == 0 {
limit = 50 limit = 50
} }
@ -223,6 +221,16 @@ func formatPkgSearchUpdatedAt(raw string) string {
return cli.FormatAge(updatedAt) return cli.FormatAge(updatedAt)
} }
func resolvePkgSearchPattern(flagPattern string, args []string) string {
if flagPattern != "" {
return flagPattern
}
if len(args) > 0 && strings.TrimSpace(args[0]) != "" {
return args[0]
}
return "*"
}
// matchGlob does simple glob matching with * wildcards // matchGlob does simple glob matching with * wildcards
func matchGlob(pattern, name string) bool { func matchGlob(pattern, name string) bool {
if pattern == "*" || pattern == "" { if pattern == "*" || pattern == "" {

View file

@ -0,0 +1,24 @@
package pkgcmd
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestResolvePkgSearchPattern_Good(t *testing.T) {
t.Run("uses flag pattern when set", func(t *testing.T) {
got := resolvePkgSearchPattern("core-*", []string{"api"})
assert.Equal(t, "core-*", got)
})
t.Run("uses positional pattern when flag is empty", func(t *testing.T) {
got := resolvePkgSearchPattern("", []string{"api"})
assert.Equal(t, "api", got)
})
t.Run("defaults to wildcard when nothing is provided", func(t *testing.T) {
got := resolvePkgSearchPattern("", nil)
assert.Equal(t, "*", got)
})
}