mirror of
https://github.com/holos-run/holos.git
synced 2026-03-19 16:54:58 +00:00
This adds a new holos subcommand: preflight Initially, this just checks that the GitHub CLI is installed and authenticated. The preflight command will be used to validate that the user has the neccessary CLI tools, access, and authorization to start using Holos and setup a Holos cluster.
67 lines
1.9 KiB
Go
67 lines
1.9 KiB
Go
package cli
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/holos-run/holos/pkg/cli/build"
|
|
"github.com/holos-run/holos/pkg/cli/create"
|
|
"github.com/holos-run/holos/pkg/cli/get"
|
|
"github.com/holos-run/holos/pkg/cli/kv"
|
|
"github.com/holos-run/holos/pkg/cli/preflight"
|
|
"github.com/holos-run/holos/pkg/cli/render"
|
|
"github.com/holos-run/holos/pkg/cli/txtar"
|
|
"github.com/holos-run/holos/pkg/holos"
|
|
"github.com/holos-run/holos/pkg/logger"
|
|
"github.com/holos-run/holos/pkg/version"
|
|
)
|
|
|
|
// New returns a new root *cobra.Command for command line execution.
|
|
func New(cfg *holos.Config) *cobra.Command {
|
|
rootCmd := &cobra.Command{
|
|
Use: "holos",
|
|
Short: "holos manages a holistic integrated software development platform",
|
|
Version: version.Version,
|
|
Args: cobra.NoArgs,
|
|
CompletionOptions: cobra.CompletionOptions{
|
|
HiddenDefaultCmd: true, // Don't complete the complete subcommand itself
|
|
},
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
PersistentPreRunE: func(c *cobra.Command, args []string) error {
|
|
if err := cfg.Finalize(); err != nil {
|
|
return err
|
|
}
|
|
log := cfg.Logger()
|
|
// Set the configured logger in the context.
|
|
c.SetContext(logger.NewContext(c.Context(), log))
|
|
// Set the default logger after flag parsing.
|
|
slog.SetDefault(log)
|
|
return nil
|
|
},
|
|
RunE: func(c *cobra.Command, args []string) error {
|
|
return c.Usage()
|
|
},
|
|
}
|
|
rootCmd.SetVersionTemplate("{{.Version}}\n")
|
|
rootCmd.SetOut(cfg.Stdout())
|
|
rootCmd.PersistentFlags().SortFlags = false
|
|
rootCmd.PersistentFlags().AddGoFlagSet(cfg.LogFlagSet())
|
|
|
|
// subcommands
|
|
rootCmd.AddCommand(build.New(cfg))
|
|
rootCmd.AddCommand(render.New(cfg))
|
|
rootCmd.AddCommand(get.New(cfg))
|
|
rootCmd.AddCommand(create.New(cfg))
|
|
rootCmd.AddCommand(preflight.New(cfg))
|
|
|
|
// Maybe not needed?
|
|
rootCmd.AddCommand(txtar.New(cfg))
|
|
|
|
// Deprecated, remove?
|
|
rootCmd.AddCommand(kv.New(cfg))
|
|
|
|
return rootCmd
|
|
}
|