package cmd

import (
	log "github.com/cloudposse/atmos/pkg/logger"
	"github.com/spf13/cobra"

	"github.com/cloudposse/atmos/internal/exec"
)

// ValidateStacksCmd validates stacks
var ValidateStacksCmd = &cobra.Command{
	Use:                "stacks",
	Short:              "Validate stack manifest configurations",
	Long:               "This command validates the configuration of stack manifests in Atmos to ensure proper setup and compliance.",
	Example:            "validate stacks",
	FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
	Args:               cobra.NoArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		// Check Atmos configuration
		checkAtmosConfig()

		err := exec.ExecuteValidateStacksCmd(cmd, args)
		if err != nil {
			return err
		}

		log.Info("All stacks validated successfully")
		return nil
	},
}

func init() {
	ValidateStacksCmd.DisableFlagParsing = false

	ValidateStacksCmd.PersistentFlags().String("schemas-atmos-manifest", "", "Specifies the path to a JSON schema file used to validate the structure and content of the Atmos manifest file")

	validateCmd.AddCommand(ValidateStacksCmd)
}
