mirror of
https://github.com/mudler/luet.git
synced 2025-09-16 15:19:24 +00:00
Add Explain() to Assertions and Packages
This commit is contained in:
@@ -53,6 +53,7 @@ type Package interface {
|
||||
GetUses() []string
|
||||
|
||||
Yaml() ([]byte, error)
|
||||
Explain()
|
||||
}
|
||||
|
||||
type PackageSet interface {
|
||||
@@ -290,3 +291,23 @@ func (p *DefaultPackage) BuildFormula() ([]bf.Formula, error) {
|
||||
}
|
||||
return formulas, nil
|
||||
}
|
||||
|
||||
func (p *DefaultPackage) Explain() {
|
||||
|
||||
fmt.Println("====================")
|
||||
fmt.Println("Name: ", p.GetName())
|
||||
fmt.Println("Category: ", p.GetCategory())
|
||||
fmt.Println("Version: ", p.GetVersion())
|
||||
fmt.Println("Installed: ", p.IsSet)
|
||||
|
||||
for _, req := range p.GetRequires() {
|
||||
fmt.Println("\t-> ", req)
|
||||
}
|
||||
|
||||
for _, con := range p.GetConflicts() {
|
||||
fmt.Println("\t!! ", con)
|
||||
}
|
||||
|
||||
fmt.Println("====================")
|
||||
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
package solver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
pkg "github.com/mudler/luet/pkg/package"
|
||||
)
|
||||
|
||||
@@ -40,3 +42,18 @@ func DecodeModel(model map[string]bool) ([]PackageAssert, error) {
|
||||
}
|
||||
return ass, nil
|
||||
}
|
||||
|
||||
func (a *PackageAssert) Explain() {
|
||||
fmt.Println(a.ToString())
|
||||
a.Package.Explain()
|
||||
}
|
||||
|
||||
func (a *PackageAssert) ToString() string {
|
||||
var msg string
|
||||
if a.Package.Flagged() {
|
||||
msg = "installed"
|
||||
} else {
|
||||
msg = "not installed"
|
||||
}
|
||||
return fmt.Sprintf("%s/%s %s %s: %t", a.Package.GetCategory(), a.Package.GetName(), a.Package.GetVersion(), msg, a.Value)
|
||||
}
|
||||
|
Reference in New Issue
Block a user