diff --git a/cmd/bbolt/README.md b/cmd/bbolt/README.md index 851f380ba..8c7785456 100644 --- a/cmd/bbolt/README.md +++ b/cmd/bbolt/README.md @@ -40,6 +40,7 @@ The commands are: + version prints the current version of bbolt bench run synthetic benchmark against bbolt buckets print a list of buckets check verifies integrity of bbolt database @@ -60,6 +61,21 @@ ## Analyse bbolt database with bbolt command line +### version + +- `version` print the current version information of bbolt command-line. +- usage: + `bbolt version` + + Example: + + ```bash + $bbolt version + bbolt version: 1.3.7 + Go Version: go1.20.7 + Go OS/Arch: darwin/arm64 + ``` + ### info - `info` print the basic information about the given Bbolt database. diff --git a/cmd/bbolt/command_root.go b/cmd/bbolt/command_root.go index b960df898..31a174080 100644 --- a/cmd/bbolt/command_root.go +++ b/cmd/bbolt/command_root.go @@ -17,6 +17,7 @@ func NewRootCommand() *cobra.Command { } rootCmd.AddCommand( + newVersionCobraCommand(), newSurgeryCobraCommand(), ) diff --git a/cmd/bbolt/command_version.go b/cmd/bbolt/command_version.go new file mode 100644 index 000000000..4434c515f --- /dev/null +++ b/cmd/bbolt/command_version.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "runtime" + + "github.com/spf13/cobra" + "go.etcd.io/bbolt/version" +) + +func newVersionCobraCommand() *cobra.Command { + versionCmd := &cobra.Command{ + Use: "version", + Short: "print the current version of bbolt", + Long: "print the current version of bbolt", + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("bbolt Version: %s\n", version.Version) + fmt.Printf("Go Version: %s\n", runtime.Version()) + fmt.Printf("Go OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + }, + } + + return versionCmd +} diff --git a/cmd/bbolt/main.go b/cmd/bbolt/main.go index 364b1fe21..7115471c0 100644 --- a/cmd/bbolt/main.go +++ b/cmd/bbolt/main.go @@ -156,6 +156,7 @@ Usage: The commands are: + version print the current version of bbolt bench run synthetic benchmark against bbolt buckets print a list of buckets check verifies integrity of bbolt database diff --git a/version/version.go b/version/version.go new file mode 100644 index 000000000..b0387d599 --- /dev/null +++ b/version/version.go @@ -0,0 +1,6 @@ +package version + +var ( + // Version shows the last bbolt binary version released. + Version = "1.3.7" +)