mirror of
https://github.com/holos-run/holos.git
synced 2026-03-19 16:54:58 +00:00
This patch adds a get secret subcommand. With no args, lists holos secrets. With args, gets each argument. The use cases are: 1. Extract specified keys to files with --to-file 2. Extract all keys to files with --extract-all 3. Print one key to stdout with --print-key If no key is specified, the key is implicitly set to the holos secret name. This behavior should be preserved as part of the api.
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
package cli
|
|
|
|
import (
|
|
"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/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"
|
|
"github.com/spf13/cobra"
|
|
"log/slog"
|
|
)
|
|
|
|
// 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))
|
|
|
|
// Maybe not needed?
|
|
rootCmd.AddCommand(txtar.New(cfg))
|
|
|
|
// Deprecated, remove?
|
|
rootCmd.AddCommand(kv.New(cfg))
|
|
|
|
return rootCmd
|
|
}
|