Skip to content

Commit

Permalink
feat: Version sub command
Browse files Browse the repository at this point in the history
Add sub command to print megophone version
  • Loading branch information
coolapso committed Oct 27, 2024
1 parent 5eae6a2 commit a9236c5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ builds:
- binary: megophone
env:
- CGO_ENABLED=0
ldflags:
- -X cmd.Version={{.Version}}

aurs:
- name: megophone-bin
homepage: "https://github.com/coolapso/megophone"
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func init() {
rootCmd.Flags().BoolP("m-only", "m", false, "Post to Mastodon Only")
rootCmd.Flags().StringP("media-path", "p", "", "Path of media to be uploaded")
rootCmd.AddCommand(configure)
rootCmd.AddCommand(versionCmd)
}

// initConfig reads in config file and ENV variables if set.
Expand Down
19 changes: 19 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

var (
Version = "DEV"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print megophone version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Megophone %s\n", Version)
},
}

0 comments on commit a9236c5

Please sign in to comment.