Skip to content

Commit

Permalink
feat: Add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
ErickKramer committed May 23, 2024
1 parent 39dfff5 commit 999853a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Available Commands:
switch Switch repository version
sync Synchronize all found repositories.
validate Validate a .repos file
version Print the version number
```

Each of the available commands have their own help with information about their usage and available flags (e.g. `rv help import`).
Expand Down
36 changes: 36 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright © 2024 Erick Kramer <[email protected]>
*/
package cmd

import (
"fmt"
"ripvcs/utils"

"github.com/spf13/cobra"
)

var (
// These variables should be set using ldflags during the build
Version = "v0.1.1"
Commit = "39dfff5"
BuildDate = "25.05.2024"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number",
Run: func(cmd *cobra.Command, args []string) {
utils.PrintSection("ripvcs (rv)")
utils.PrintSeparator()
fmt.Printf("%sVersion:%s %s\n", utils.BlueColor, utils.ResetColor, Version)
fmt.Printf("%sCommit:%s %s\n", utils.BlueColor, utils.ResetColor, Commit)
fmt.Printf("%sBuild Date:%s %s\n", utils.BlueColor, utils.ResetColor, BuildDate)
utils.PrintSeparator()
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}

0 comments on commit 999853a

Please sign in to comment.