package main

import (
	"os"

	"github.com/spf13/cobra"
	"go.uber.org/zap"
)

var (
	cfgFile  string
	logLevel string
	logger   *zap.Logger
	version  = "dev"
)

var rootCmd = &cobra.Command{
	Use:   "vecna",
	Short: "Embedding dimension adapter — translate vectors between model spaces",
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		var err error
		if logLevel == "debug" {
			logger, err = zap.NewDevelopment()
		} else {
			logger, err = zap.NewProduction()
		}
		return err
	},
}

func init() {
	rootCmd.PersistentFlags().StringVar(&cfgFile, "config", os.Getenv("VECNA_CONFIG"), "config file path (env: VECNA_CONFIG; default search: /config, $HOME, ./)")
	rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "log level: info | debug")
	rootCmd.AddCommand(convertCmd)
	rootCmd.AddCommand(serveCmd)
	rootCmd.AddCommand(versionCmd)
}

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