package cli

import (
	"github.com/spf13/cobra"
)

var versionCmd = &cobra.Command{
	Use:   "version",
	Short: "Print version information",
	Long:  "Print the orca version, git commit, and build time.",
	RunE: func(cmd *cobra.Command, args []string) error {
		info := map[string]string{
			"version":    version,
			"git_commit": gitCommit,
			"build_time": buildTime,
		}
		if jsonOutput {
			return printJSON(info)
		}
		printText("orca version %s\n", version)
		printText("  git commit: %s\n", gitCommit)
		printText("  build time: %s\n", buildTime)
		return nil
	},
}

func init() {
	rootCmd.AddCommand(versionCmd)
}
