package cmd

import (
	"os"

	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"gmgauthier.com/grokkit/config"
)

var rootCmd = &cobra.Command{
	Use:   "grokkit",
	Short: "Personal Grok / xAI command-line toolkit",
	Long:  `A fast, native Go CLI for Grok. Chat, edit files, and supercharge your git workflow.`,
}

func Execute() {
	if err := rootCmd.Execute(); err != nil {
		os.Exit(1)
	}
}

func init() {
	config.InitConfig()
	rootCmd.PersistentFlags().StringP("model", "m", "grok-4", "Grok model (grok-4, grok-3, etc.)")
	viper.BindPFlag("model", rootCmd.PersistentFlags().Lookup("model"))

	rootCmd.AddCommand(chatCmd)
	rootCmd.AddCommand(editCmd)
	rootCmd.AddCommand(reviewCmd)
	rootCmd.AddCommand(commitMsgCmd)
	rootCmd.AddCommand(commitCmd)
	rootCmd.AddCommand(prDescribeCmd)
	rootCmd.AddCommand(historyCmd)
}
