mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
Update all package managers to return InstallResult/RemoveResult
Change Install and Remove method signatures across all package manager
implementations (apt, apk, dnf, pacman, rpm, dpkg, snap, flatpak, ports,
pkg) to match the updated Manager interface.
- Wrapper files: update Install/Remove to return (snack.InstallResult, error)
and (snack.RemoveResult, error) respectively
- Platform files (_linux.go, _openbsd.go, _freebsd.go): implement pre-check
logic using isInstalled() to classify packages as unchanged or to-process,
run command on actionable packages only, then collect results with version()
- Stub files (_other.go): return (snack.InstallResult{}, ErrUnsupportedPlatform)
and (snack.RemoveResult{}, ErrUnsupportedPlatform)
- DNF special case: add v5 bool parameter to internal install/remove functions
and thread d.v5 from the wrapper; update Purge to discard the result
- cmd/snack/main.go: update install/remove commands to discard InstallResult/
RemoveResult and return only the error to cobra
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
11
dnf/dnf.go
11
dnf/dnf.go
@@ -31,24 +31,25 @@ func (d *DNF) Name() string { return "dnf" }
|
||||
func (d *DNF) Available() bool { return available() }
|
||||
|
||||
// Install one or more packages.
|
||||
func (d *DNF) Install(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) error {
|
||||
func (d *DNF) Install(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) (snack.InstallResult, error) {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
return install(ctx, pkgs, opts...)
|
||||
return install(ctx, d.v5, pkgs, opts...)
|
||||
}
|
||||
|
||||
// Remove one or more packages.
|
||||
func (d *DNF) Remove(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) error {
|
||||
func (d *DNF) Remove(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) (snack.RemoveResult, error) {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
return remove(ctx, pkgs, opts...)
|
||||
return remove(ctx, d.v5, pkgs, opts...)
|
||||
}
|
||||
|
||||
// Purge removes packages including configuration files (same as Remove for dnf).
|
||||
func (d *DNF) Purge(ctx context.Context, pkgs []snack.Target, opts ...snack.Option) error {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
return remove(ctx, pkgs, opts...)
|
||||
_, err := remove(ctx, d.v5, pkgs, opts...)
|
||||
return err
|
||||
}
|
||||
|
||||
// Upgrade all installed packages to their latest versions.
|
||||
|
||||
Reference in New Issue
Block a user