package cmd

import (
	"github.com/spf13/cobra"
	"yizhisec.com/hsv2/forge/internal/controller/maker"
)

func makeRedis() *cobra.Command {
	var (
		replicas int
		password string
		storage  string
	)

	_cmd := &cobra.Command{
		Use:   "redis",
		Short: "Build Redis resources",
		Long:  `Build and prepare Redis cache resources.`,
		RunE: func(cmd *cobra.Command, args []string) error {
			mk := maker.NewMaker()
			return mk.Redis(
				cmd.Context(),
				maker.WithRedisReplicaCount(replicas),
				maker.WithRedisPassword(password),
				maker.WithRedisStorage(storage),
			)
		},
	}

	_cmd.Flags().IntVar(&replicas, "replica-count", 2, "Redis 副本数")
	_cmd.Flags().StringVar(&password, "password", "", "Redis 密码")
	_cmd.Flags().StringVar(&storage, "storage-size", "5Gi", "Redis 存储大小(如: 5Gi)")

	return _cmd
}
