github.com/cockroachdb/pebble@v1.1.1-0.20240513155919-3622ade60459/cmd/pebble/fsbenchlist.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/cockroachdb/errors" 7 "github.com/spf13/cobra" 8 ) 9 10 var listFsBench = &cobra.Command{ 11 Use: "list [<name>] [<name>] ...", 12 Short: "List the available file system benchmarks.", 13 Long: ` 14 List the available file system benchmarks. If no <name> is supplied 15 as an argument, then all the available benchmark names are printed. 16 If one or more <name>s are supplied as arguments, then the benchmark 17 descriptions are printed out for those names. 18 `, 19 RunE: runListFsBench, 20 } 21 22 func runListFsBench(_ *cobra.Command, args []string) error { 23 if len(args) == 0 { 24 fmt.Println("Available benchmarks:") 25 for name := range benchmarks { 26 fmt.Println(name) 27 } 28 } else { 29 for _, v := range args { 30 benchStruct, ok := benchmarks[v] 31 if !ok { 32 return errors.Errorf("trying to print out the description for unknown benchmark: %s", v) 33 } 34 fmt.Println("Name:", benchStruct.name) 35 fmt.Println("Description:", benchStruct.description) 36 } 37 } 38 return nil 39 }