package cmds

import (
	"context"
	"log/slog"
	"time"

	"git.ma-al.com/goc_daniel/b2b/app/db"
	genmodels "git.ma-al.com/goc_daniel/b2b/app/utils/genModels"
	"github.com/spf13/cobra"
)

var generateModelsCmd = &cobra.Command{
	Use:   "genmodels",
	Short: "generate input database models",
	Run: func(cmd *cobra.Command, args []string) {
		ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
		defer cancel()

		err := genmodels.New(db.Get()).GormGenModels(ctx)
		if err != nil {
			slog.Error("Error performing work: " + err.Error())
		}
	},
}
