Add version

This commit is contained in:
Melroy van den Berg 2025-04-24 18:29:42 +02:00
parent 89e6420aee
commit 795a95e573
No known key found for this signature in database
GPG key ID: 71D11FF23454B9D7

View file

@ -10,14 +10,22 @@ import (
"gitlab.melroy.org/melroy/fediresolve/resolver"
)
const Version = "1.0"
var versionFlag bool
var rootCmd = &cobra.Command{
Use: "fediresolve [url|handle]",
Short: "Resolve and display Fediverse content",
Short: "Resolve and display Fediverse content (v" + Version + ")",
Long: `Fediresolve is a CLI tool that resolves Fediverse URLs and handles.
It can parse and display content from Mastodon, Mbin, Lemmy, and other Fediverse platforms.
The tool supports both direct URLs to posts/comments/threads and Fediverse handles like @username@server.com.`,
Run: func(cmd *cobra.Command, args []string) {
if versionFlag {
fmt.Println("fediresolve version", Version)
os.Exit(0)
}
var input string
if len(args) > 0 {
@ -45,6 +53,10 @@ The tool supports both direct URLs to posts/comments/threads and Fediverse handl
},
}
func init() {
rootCmd.PersistentFlags().BoolVar(&versionFlag, "version", false, "Print the version number and exit")
}
// Execute adds all child commands to the root command and sets flags appropriately.
func Execute() error {
return rootCmd.Execute()