Add Explain() to Assertions and Packages

This commit is contained in:
Ettore Di Giacinto
2019-10-31 12:34:28 +01:00
parent 7f848ee5ef
commit e5db47a679
2 changed files with 38 additions and 0 deletions

View File

@@ -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)
}