feat: add advanced update management features

This commit is contained in:
2026-05-03 22:55:51 +02:00
parent a22d2e16ea
commit 137290e3d7
7 changed files with 644 additions and 150 deletions

View File

@@ -12,6 +12,7 @@ type Package struct {
Name string
Current string
Available string
Ignored bool
}
type Result struct {
@@ -20,11 +21,28 @@ type Result struct {
}
type Options struct {
CheckAUR bool
CheckAUR bool
IgnoredPackages []string
}
func (r Result) Total() int {
return len(r.Packages)
total := 0
for _, pkg := range r.Packages {
if !pkg.Ignored {
total++
}
}
return total
}
func (r Result) IgnoredTotal() int {
total := 0
for _, pkg := range r.Packages {
if pkg.Ignored {
total++
}
}
return total
}
func (r Result) Summary() string {
@@ -60,9 +78,26 @@ func CheckWithOptions(ctx context.Context, opts Options) (Result, error) {
result.Packages = append(result.Packages, aur...)
}
markIgnored(&result, opts.IgnoredPackages)
return result, nil
}
func markIgnored(result *Result, names []string) {
ignored := map[string]bool{}
for _, name := range names {
name = strings.TrimSpace(name)
if name != "" {
ignored[name] = true
}
}
if len(ignored) == 0 {
return
}
for i := range result.Packages {
result.Packages[i].Ignored = ignored[result.Packages[i].Name]
}
}
func checkPacman(ctx context.Context) ([]Package, error) {
if _, err := exec.LookPath("checkupdates"); err == nil {
out, err := exec.CommandContext(ctx, "checkupdates").Output()