2023-06-19 18:19:56 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2023-06-20 17:00:20 +00:00
|
|
|
"os"
|
2023-06-19 18:19:56 +00:00
|
|
|
|
|
|
|
"code.icb4dc0.de/buildr/buildr/internal/slices"
|
|
|
|
"code.icb4dc0.de/buildr/buildr/modules"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ModulesCommand(
|
|
|
|
initializer LevelInitializer,
|
|
|
|
registryAcc TypeRegistryAccessor,
|
|
|
|
manCmder ManCommander,
|
|
|
|
moduleCmder BootstrapModuleCommander,
|
|
|
|
) *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
2023-06-29 18:14:52 +00:00
|
|
|
Use: "modules",
|
|
|
|
Aliases: []string{"mod", "mods"},
|
|
|
|
Short: "Interact with modules",
|
|
|
|
SilenceUsage: true,
|
|
|
|
SilenceErrors: true,
|
2023-06-19 18:19:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd.AddCommand(
|
2023-06-20 17:00:20 +00:00
|
|
|
ModulesListCommand(initializer, registryAcc, os.Stdout),
|
2023-06-19 18:19:56 +00:00
|
|
|
ManCmd(manCmder, initializer, registryAcc),
|
|
|
|
NewCmd(
|
|
|
|
slices.Map(modules.Categories(), func(c modules.Category) *cobra.Command {
|
|
|
|
return BootstrapModuleCmd(
|
|
|
|
c,
|
|
|
|
moduleCmder,
|
|
|
|
ModulesArgsProviderFor(initializer, registryAcc, c),
|
2023-09-12 16:43:34 +00:00
|
|
|
WithShort(fmt.Sprintf("Bootstrap %s module", modules.CategoryName(c))),
|
2023-06-19 18:19:56 +00:00
|
|
|
)
|
|
|
|
})...,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|