Skip to content

Commit

Permalink
feat: add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
doron-cohen committed Sep 19, 2020
1 parent da3e349 commit ca14350
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ var rootCmd = &cobra.Command{
Use: "antidot",
Short: "Clean your $HOME from those pesky dotfiles",
Run: func(cmd *cobra.Command, args []string) {

},
}

func Execute() {
func Execute(appVersion string) {
rootCmd.Version = appVersion
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import (
"github.com/doron-cohen/antidot/cmd"
)

/*
We are injecting the app's version to this variable.
This is done using: go build -ldflags "-X 'main.version=$VERSION".
It is only used in the cmd package but I couldn't make it inject there.
*/
var version = "dev"

func main() {
cmd.Execute()
cmd.Execute(version)
}

0 comments on commit ca14350

Please sign in to comment.