mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
Pass 1 (Feature & Completeness): - Replace apt CLI with apt-get for listUpgrades (apt CLI is unstable for scripting) - Verify snapd daemon is running in snap Available() check - Add ErrDaemonNotRunning sentinel error for daemon-dependent managers - Fix staticcheck S1011: replace loop with append(keys, matches...) - Fix staticcheck SA1012: use context.TODO() instead of nil in dpkg tests
38 lines
888 B
Go
38 lines
888 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,
|
|
}
|
|
}
|