mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
feat(winget): add Windows Package Manager support
Implements the full snack.Manager interface for winget: - Install/Remove/Purge/Upgrade via winget CLI - Search/List/Info/IsInstalled/Version queries - Source (repository) management via RepoManager - Version querying via VersionQuerier - Targeted package upgrades via PackageUpgrader - Name normalization via NameNormalizer All commands use --disable-interactivity, --accept-source-agreements, and --accept-package-agreements for non-interactive operation. Parser handles winget's fixed-width tabular output by detecting column positions from the header/separator lines. Includes VT100 escape sequence stripping and progress line filtering. Windows-only via build tags; other platforms return ErrUnsupportedPlatform. Registered in detect_windows.go as the default Windows package manager.
This commit is contained in:
49
winget/capabilities.go
Normal file
49
winget/capabilities.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package winget
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogrlx/snack"
|
||||
)
|
||||
|
||||
// Compile-time interface checks.
|
||||
var (
|
||||
_ snack.VersionQuerier = (*Winget)(nil)
|
||||
_ snack.RepoManager = (*Winget)(nil)
|
||||
_ snack.NameNormalizer = (*Winget)(nil)
|
||||
)
|
||||
|
||||
// LatestVersion returns the latest available version of a package.
|
||||
func (w *Winget) LatestVersion(ctx context.Context, pkg string) (string, error) {
|
||||
return latestVersion(ctx, pkg)
|
||||
}
|
||||
|
||||
// ListUpgrades returns packages that have newer versions available.
|
||||
func (w *Winget) ListUpgrades(ctx context.Context) ([]snack.Package, error) {
|
||||
return listUpgrades(ctx)
|
||||
}
|
||||
|
||||
// UpgradeAvailable reports whether a newer version is available.
|
||||
func (w *Winget) UpgradeAvailable(ctx context.Context, pkg string) (bool, error) {
|
||||
return upgradeAvailable(ctx, pkg)
|
||||
}
|
||||
|
||||
// VersionCmp compares two version strings.
|
||||
func (w *Winget) VersionCmp(ctx context.Context, ver1, ver2 string) (int, error) {
|
||||
return versionCmp(ctx, ver1, ver2)
|
||||
}
|
||||
|
||||
// ListRepos returns configured winget sources.
|
||||
func (w *Winget) ListRepos(ctx context.Context) ([]snack.Repository, error) {
|
||||
return sourceList(ctx)
|
||||
}
|
||||
|
||||
// AddRepo adds a new winget source.
|
||||
func (w *Winget) AddRepo(ctx context.Context, repo snack.Repository) error {
|
||||
return sourceAdd(ctx, repo)
|
||||
}
|
||||
|
||||
// RemoveRepo removes a configured winget source.
|
||||
func (w *Winget) RemoveRepo(ctx context.Context, id string) error {
|
||||
return sourceRemove(ctx, id)
|
||||
}
|
||||
Reference in New Issue
Block a user