fix: allow pkg update without package args
All checks were successful
Security Scan / security (push) Successful in 20s

This commit is contained in:
Virgil 2026-04-02 05:16:51 +00:00
parent e29b6e4889
commit 58f07603cd
2 changed files with 15 additions and 4 deletions

View file

@ -165,9 +165,6 @@ func addPkgUpdateCommand(parent *cobra.Command) {
Short: i18n.T("cmd.pkg.update.short"),
Long: i18n.T("cmd.pkg.update.long"),
RunE: func(cmd *cobra.Command, args []string) error {
if !updateAll && len(args) == 0 {
return errors.New(i18n.T("cmd.pkg.error.specify_package"))
}
return runPkgUpdate(args, updateAll)
},
}
@ -197,7 +194,7 @@ func runPkgUpdate(packages []string, all bool) error {
}
var toUpdate []string
if all {
if all || len(packages) == 0 {
for _, r := range reg.List() {
toUpdate = append(toUpdate, r.Name)
}

View file

@ -291,3 +291,17 @@ func TestRunPkgSearch_RespectsLimitWithCachedResults(t *testing.T) {
assert.Contains(t, out, "core-alpha")
assert.NotContains(t, out, "core-beta")
}
func TestRunPkgUpdate_NoArgs_UpdatesAll(t *testing.T) {
tmp := setupOutdatedRegistry(t)
withWorkingDir(t, tmp)
out := capturePkgOutput(t, func() {
err := runPkgUpdate(nil, false)
require.NoError(t, err)
})
assert.Contains(t, out, "updating")
assert.Contains(t, out, "core-fresh")
assert.Contains(t, out, "core-stale")
}