package cmd import ( "fmt" "github.com/spf13/cobra" ) func init() { rootCmd.AddCommand( newVersionCmd(), ) } // Version, CommitSHA, and BuildDate are set at build time using ldflags. var ( Version = "dev" CommitSHA = "none" BuildDate = "unknown" ) // newVersionCmd creates the version command for displaying version information. func newVersionCmd() *cobra.Command { var short bool cmd := &cobra.Command{ Use: "version", Short: "Show version", Long: "Display version information for the agence application.", Run: func(cmd *cobra.Command, args []string) { if short { fmt.Println(Version) return } fmt.Printf("lassistanoque %s (commit: %s, built: %s)\n", Version, CommitSHA, BuildDate) }, } cmd.Flags().BoolVarP(&short, "short", "s", false, "show only version number") return cmd }