Skip to content

Commit

Permalink
cmd/pebble: add version flag
Browse files Browse the repository at this point in the history
Add a version flag to `pebble` and `pebble db` which prints the
supported format versions.

```
$ go run ./cmd/pebble --version
pebble benchmarking/introspection tool
supported Pebble format versions: 13-19
$ go run ./cmd/pebble db --version
DB introspection tools
supported Pebble format versions: 13-19
```
  • Loading branch information
RaduBerinde committed Jan 1, 2025
1 parent 33e4a33 commit 6b0e4c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions cmd/pebble/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
package main

import (
"fmt"
"log"
"os"
"time"

"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/internal/base"
"github.com/cockroachdb/pebble/internal/crdbtest"
"github.com/cockroachdb/pebble/internal/testkeys"
Expand Down Expand Up @@ -68,9 +70,13 @@ func main() {
)

rootCmd := &cobra.Command{
Use: "pebble [command] (flags)",
Short: "pebble benchmarking/introspection tool",
Use: "pebble [command] (flags)",
Short: "pebble benchmarking/introspection tool",
Version: fmt.Sprintf("supported Pebble format versions: %d-%d", pebble.FormatMinSupported, pebble.FormatNewest),
}
rootCmd.SetVersionTemplate(`{{printf "%s" .Short}}
{{printf "%s" .Version}}
`)
rootCmd.AddCommand(benchCmd)

t := tool.New(
Expand Down
8 changes: 6 additions & 2 deletions tool/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ func newDB(
d.fmtValue.mustSet("[%x]")

d.Root = &cobra.Command{
Use: "db",
Short: "DB introspection tools",
Use: "db",
Short: "DB introspection tools",
Version: fmt.Sprintf("supported Pebble format versions: %d-%d", pebble.FormatMinSupported, pebble.FormatNewest),
}
d.Root.SetVersionTemplate(`{{printf "%s" .Short}}
{{printf "%s" .Version}}
`)
d.Check = &cobra.Command{
Use: "check <dir>",
Short: "verify checksums and metadata",
Expand Down

0 comments on commit 6b0e4c8

Please sign in to comment.