Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CheckCmd = &cobra.Command{ Use: "check [recipe-dir]", Short: "check a directory of recipes", Long: ` The "check" subcommand checks that all recipes in a directory are valid.`, Example: `webman check ~/repos/webman-pkgs/`, RunE: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return cmd.Help() } recipeDir, err := filepath.Abs(args[0]) utils.WebmanRecipeDir = recipeDir if err != nil { return err } entries, err := os.ReadDir(filepath.Join(recipeDir, "pkgs")) if err != nil { return err } else { var wg sync.WaitGroup success := true wg.Add(len(entries)) for _, recipe := range entries { recipe := recipe go func() { recipeName := recipe.Name() pkg := strings.ReplaceAll(recipeName, utils.PkgRecipeExt, "") err := CheckPkgConfig(pkg) if err != nil { var lintErr schema.ResultErrors if errors.As(err, &lintErr) { for _, le := range lintErr { color.Red("%s: %s", color.YellowString(recipeName), color.RedString("%s: %s", le.Field(), le.Description())) } } else { color.Red("%s: %s", color.YellowString(recipeName), color.RedString("%v", err)) } success = false } wg.Done() }() } wg.Wait() if !success { return fmt.Errorf("Not all packages are valid!") } color.Green("All packages are valid!") groupsPath := filepath.Join(recipeDir, "groups") groups, err := os.ReadDir(groupsPath) if err != nil { return err } var wg2 sync.WaitGroup success = true wg2.Add(len(groups)) for _, groupEntry := range groups { groupEntry := groupEntry go func() { recipeName := groupEntry.Name() group := strings.ReplaceAll(recipeName, utils.GroupRecipeExt, "") if err := CheckGroup(filepath.Join(groupsPath, recipeName)); err != nil { color.Red("%s: %s", color.MagentaString(group), color.RedString("%v", err)) success = false } wg2.Done() }() } wg2.Wait() if !success { return fmt.Errorf("Not all groups are valid!") } color.Green("All groups are valid!") return nil } }, }
CheckCmd represents the remove command
Functions ¶
func CheckGroup ¶
func CheckPkgConfig ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.