mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
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.
20 lines
665 B
Go
20 lines
665 B
Go
package winget
|
|
|
|
import "strings"
|
|
|
|
// normalizeName returns the canonical form of a winget package ID.
|
|
// Winget IDs use dot-separated Publisher.Package format (e.g.
|
|
// "Microsoft.VisualStudioCode"). This trims whitespace but otherwise
|
|
// preserves the ID as-is since winget IDs are case-insensitive but
|
|
// conventionally PascalCase.
|
|
func normalizeName(name string) string {
|
|
return strings.TrimSpace(name)
|
|
}
|
|
|
|
// parseArch extracts the architecture from a winget package name if present.
|
|
// Winget IDs do not include architecture suffixes, so this returns the
|
|
// name unchanged with an empty string.
|
|
func parseArch(name string) (string, string) {
|
|
return name, ""
|
|
}
|