Files
snack/capabilities.go
Tai Groot ef81e027ce feat: add capability interfaces for extended package manager operations
Add optional interfaces that providers can implement beyond the base
Manager. grlx can type-assert to check support at runtime:

- VersionQuerier: LatestVersion, ListUpgrades, UpgradeAvailable, VersionCmp
- Holder: Hold, Unhold, ListHeld (version pinning)
- Cleaner: Autoremove, Clean (orphan/cache cleanup)
- FileOwner: FileList, Owner (file-to-package mapping)
- RepoManager: ListRepos, AddRepo, RemoveRepo
- KeyManager: AddKey, RemoveKey, ListKeys (GPG signing keys)
- Grouper: GroupList, GroupInfo, GroupInstall
- NameNormalizer: NormalizeName, ParseArch

Also adds GetCapabilities() helper, Repository type, and updated README.
2026-02-25 20:42:04 +00:00

38 lines
896 B
Go

package snack
// Capabilities reports which optional interfaces a Manager implements.
// Useful for grlx to determine what operations are available before
// attempting them.
type Capabilities struct {
VersionQuery bool
Hold bool
Clean bool
FileOwnership bool
RepoManagement bool
KeyManagement bool
Groups bool
NameNormalize bool
}
// GetCapabilities probes a Manager for all optional interface support.
func GetCapabilities(m Manager) Capabilities {
_, vq := m.(VersionQuerier)
_, h := m.(Holder)
_, c := m.(Cleaner)
_, fo := m.(FileOwner)
_, rm := m.(RepoManager)
_, km := m.(KeyManager)
_, g := m.(Grouper)
_, nn := m.(NameNormalizer)
return Capabilities{
VersionQuery: vq,
Hold: h,
Clean: c,
FileOwnership: fo,
RepoManagement: rm,
KeyManagement: km,
Groups: g,
NameNormalize: nn,
}
}