mirror of
https://github.com/foomo/sesamy-cli.git
synced 2025-10-16 12:35:36 +00:00
32 lines
698 B
Go
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
|
|
}
|