Files
kontor/kontor-gin/internal/cmd/root.go
T
tpeetz bc88c694ee
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
add MediaLofi in kontor-gin (#97)
Co-authored-by: Thomas Peetz <thomas.peetz@cimt-ag.de>
Reviewed-on: #97
2026-10-09 16:26:11 +00:00

42 lines
1.3 KiB
Go

package cmd
import (
"fmt"
"kontor-api-gin/internal/config"
"log/slog"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "kontor-cli",
TraverseChildren: true,
Short: "A brief description of your application",
Long: ``,
// Uncomment the following line if your bare application
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
slog.Info("Verbosity level", "level", config.Verbose)
},
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Oops. An error while executing Zero '%s'\n", err)
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().StringVarP(&config.CfgFile, "config", "c", "/home/tpeetz/.config/kli.yaml", "config file")
rootCmd.PersistentFlags().CountVarP(&config.Verbose, "verbose", "v", "increase verbosity (-v, -vv, -vvv)")
viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
exportCmd.Flags().StringVarP(&config.ServerName, "servername", "s", "local", "Define server to get Kontor items")
viper.BindPFlag("server", exportCmd.PersistentFlags().Lookup("server"))
cobra.OnInitialize(config.InitCliConfig)
}