mirror of
https://github.com/mudler/luet.git
synced 2025-08-31 23:02:16 +00:00
cmd/tree/validate: Now support multiple tree paths
This commit is contained in:
@@ -34,14 +34,14 @@ import (
|
|||||||
func NewTreeValidateCommand() *cobra.Command {
|
func NewTreeValidateCommand() *cobra.Command {
|
||||||
var excludes []string
|
var excludes []string
|
||||||
var matches []string
|
var matches []string
|
||||||
|
var treePaths []string
|
||||||
|
|
||||||
var ans = &cobra.Command{
|
var ans = &cobra.Command{
|
||||||
Use: "validate [OPTIONS]",
|
Use: "validate [OPTIONS]",
|
||||||
Short: "Validate a tree or a list of packages",
|
Short: "Validate a tree or a list of packages",
|
||||||
Args: cobra.OnlyValidArgs,
|
Args: cobra.OnlyValidArgs,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
t, _ := cmd.Flags().GetString("tree")
|
if len(treePaths) < 1 {
|
||||||
if t == "" {
|
|
||||||
Fatal("Mandatory tree param missing.")
|
Fatal("Mandatory tree param missing.")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -53,13 +53,14 @@ func NewTreeValidateCommand() *cobra.Command {
|
|||||||
|
|
||||||
brokenPkgs := 0
|
brokenPkgs := 0
|
||||||
brokenDeps := 0
|
brokenDeps := 0
|
||||||
treePath, _ := cmd.Flags().GetString("tree")
|
|
||||||
withSolver, _ := cmd.Flags().GetBool("with-solver")
|
withSolver, _ := cmd.Flags().GetBool("with-solver")
|
||||||
|
|
||||||
reciper := tree.NewInstallerRecipe(pkg.NewInMemoryDatabase(false))
|
reciper := tree.NewInstallerRecipe(pkg.NewInMemoryDatabase(false))
|
||||||
err := reciper.Load(treePath)
|
for _, treePath := range treePaths {
|
||||||
if err != nil {
|
err := reciper.Load(treePath)
|
||||||
Fatal("Error on load tree ", err)
|
if err != nil {
|
||||||
|
Fatal("Error on load tree ", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emptyInstallationDb := pkg.NewInMemoryDatabase(false)
|
emptyInstallationDb := pkg.NewInMemoryDatabase(false)
|
||||||
@@ -200,7 +201,8 @@ func NewTreeValidateCommand() *cobra.Command {
|
|||||||
|
|
||||||
ans.Flags().BoolP("with-solver", "s", false,
|
ans.Flags().BoolP("with-solver", "s", false,
|
||||||
"Enable check of requires also with solver.")
|
"Enable check of requires also with solver.")
|
||||||
ans.Flags().StringP("tree", "t", "", "Path of the tree to use.")
|
ans.Flags().StringSliceVarP(&treePaths, "tree", "t", []string{},
|
||||||
|
"Path of the tree to use.")
|
||||||
ans.Flags().StringSliceVarP(&excludes, "exclude", "e", []string{},
|
ans.Flags().StringSliceVarP(&excludes, "exclude", "e", []string{},
|
||||||
"Exclude matched packages from analysis. (Use string as regex).")
|
"Exclude matched packages from analysis. (Use string as regex).")
|
||||||
ans.Flags().StringSliceVarP(&matches, "matches", "m", []string{},
|
ans.Flags().StringSliceVarP(&matches, "matches", "m", []string{},
|
||||||
|
Reference in New Issue
Block a user