refactor: store version in constants

This commit is contained in:
Stavros
2025-05-20 16:39:27 +03:00
parent 415eea6fab
commit 91e3bbc9d9
9 changed files with 122 additions and 56 deletions

24
cmd/version.go Normal file
View File

@@ -0,0 +1,24 @@
package cmd
import (
"fmt"
"tinyauth/internal/constants"
"github.com/spf13/cobra"
)
// Create the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of Tinyauth",
Long: `All software has versions. This is Tinyauth's`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Version: %s\n", constants.Version)
fmt.Printf("Commit Hash: %s\n", constants.CommitHash)
fmt.Printf("Build Timestamp: %s\n", constants.BuildTimestamp)
},
}
func init() {
rootCmd.AddCommand(versionCmd)
}