43 lines
950 B
Go
43 lines
950 B
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log/slog"
|
|
"os"
|
|
|
|
"git.bissendorf.co/bissendorf/unifood/m/v2/core/services/jlog"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "unifood",
|
|
Short: "Unifood is a CLI for retrieving restaurant information",
|
|
Long: ``,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
},
|
|
}
|
|
|
|
func Execute() {
|
|
initRootCmd()
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func initRootCmd() {
|
|
var appConfig AppConfig
|
|
|
|
rootCmd.PersistentFlags().BoolVarP(&appConfig.OutputVerbose, "verbose", "v", false, "Enable verbose output")
|
|
rootCmd.PersistentFlags().StringVarP(&appConfig.OutputMode, "output", "o", "json", "Set output format")
|
|
|
|
logger := jlog.New(slog.LevelDebug)
|
|
ctx := jlog.ContextWith(context.Background(), logger)
|
|
|
|
logger.Debug("Register verb commands")
|
|
rootCmd.AddCommand(getVerbs(ctx, appConfig)...)
|
|
logger.Debug("Verb commands registered successfully")
|
|
}
|