sesamy-cli/cmd/root.go
2025-04-11 10:26:47 +02:00

32 lines
698 B
Go

package cmd
import (
"log/slog"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// NewRoot represents the base command when called without any subcommands
func NewRoot(l *slog.Logger) *cobra.Command {
c := viper.New()
cmd := &cobra.Command{
Use: "sesamy",
Short: "Server Side Tag Management System",
SilenceErrors: true,
SilenceUsage: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
pterm.PrintDebugMessages = viper.GetBool("verbose")
},
}
flags := cmd.PersistentFlags()
flags.BoolP("verbose", "v", false, "output debug information")
_ = c.BindPFlag("verbose", flags.Lookup("verbose"))
return cmd
}