package version

import (
	"fmt"

	"github.com/spf13/cobra"

	pcmd "github.com/confluentinc/cli/internal/pkg/cmd"
	"github.com/confluentinc/cli/internal/pkg/utils"
	"github.com/confluentinc/cli/internal/pkg/version"
)

// Returns the Cobra command for the version.
func New(prerunner pcmd.PreRunner, v *version.Version) *cobra.Command {
	cliCmd := pcmd.NewAnonymousCLICommand(
		&cobra.Command{
			Use:   "version",
			Short: fmt.Sprintf("Show version of the %s.", version.FullCLIName),
			Run: func(cmd *cobra.Command, _ []string) {
				utils.Println(cmd, v)
			},
			Args: cobra.NoArgs,
		}, prerunner)
	return cliCmd.Command
}
