mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-12 02:00:49 +08:00
Added version command
This commit is contained in:
@@ -24,6 +24,7 @@ type cmdlineArgs struct {
|
|||||||
CheckDuplicated struct{} `cmd:"" name:"check-duplicates" help:"Check for duplicated indexes."`
|
CheckDuplicated struct{} `cmd:"" name:"check-duplicates" help:"Check for duplicated indexes."`
|
||||||
CheckAll struct{} `cmd:"" name:"check-all" help:"Check for unused and duplicated indexes."`
|
CheckAll struct{} `cmd:"" name:"check-all" help:"Check for unused and duplicated indexes."`
|
||||||
ShowHelp struct{} `cmd:"" default:"1"`
|
ShowHelp struct{} `cmd:"" default:"1"`
|
||||||
|
Version struct{} `cmd:"" name:"version"`
|
||||||
|
|
||||||
AllDatabases bool `name:"all-databases" xor:"db" help:"Check in all databases excluding system dbs"`
|
AllDatabases bool `name:"all-databases" xor:"db" help:"Check in all databases excluding system dbs"`
|
||||||
Databases []string `name:"databases" xor:"db" help:"Comma separated list of databases to check"`
|
Databases []string `name:"databases" xor:"db" help:"Comma separated list of databases to check"`
|
||||||
@@ -39,10 +40,29 @@ type response struct {
|
|||||||
Duplicated []indexes.Duplicate
|
Duplicated []indexes.Duplicate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
TOOLNAME = "pt-mongodb-index-check"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Build string = "2020-04-23" //nolint
|
||||||
|
GoVersion string = "1.14.1" //nolint
|
||||||
|
Version string = "3.4.0" //nolint
|
||||||
|
Commit string //nolint
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var args cmdlineArgs
|
var args cmdlineArgs
|
||||||
kongctx := kong.Parse(&args, kong.UsageOnError())
|
kongctx := kong.Parse(&args, kong.UsageOnError())
|
||||||
|
|
||||||
|
if kongctx.Command() == "version" {
|
||||||
|
fmt.Println(TOOLNAME)
|
||||||
|
fmt.Printf("Version %s\n", Version)
|
||||||
|
fmt.Printf("Build: %s using %s\n", Build, GoVersion)
|
||||||
|
fmt.Printf("Commit: %s\n", Commit)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user