Skip to content

Commit

Permalink
chore: add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
jon4hz committed Nov 21, 2024
1 parent 7c03170 commit f07c1dd
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import (
"github.com/charmbracelet/log"
"github.com/charmbracelet/x/term"
"github.com/jon4hz/awoolt/config"
"github.com/jon4hz/awoolt/version"
"github.com/openbao/openbao/api/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var rootCmd = &cobra.Command{
Use: "awoolt",
Short: "interactively browse vault/openbao in the terminal.",
Run: root,
Use: "awoolt",
Short: "interactively browse vault/openbao in the terminal.",
Version: version.Version,
Run: root,
}

var rootFlags struct {
Expand All @@ -39,6 +41,7 @@ func init() {
rootCmd.Flags().StringVarP(&rootFlags.path, "path", "p", "", "secret path")

must(viper.BindPFlags(rootCmd.Flags()))
rootCmd.AddCommand(versionCmd)
}

func root(cmd *cobra.Command, _ []string) {
Expand Down Expand Up @@ -151,6 +154,17 @@ func printSecret(s *api.KVSecret) {
}
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version info",
Run: func(_ *cobra.Command, _ []string) {
fmt.Printf("Version: %s\n", version.Version)
fmt.Printf("Commit: %s\n", version.Commit)
fmt.Printf("Date: %s\n", version.Date)
fmt.Printf("BuiltBy: %s\n", version.BuiltBy)
},
}

func main() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
Expand Down

0 comments on commit f07c1dd

Please sign in to comment.