mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-20 02:44:58 +00:00
Fix: --version formatting
This commit is contained in:
@@ -12,13 +12,20 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ldflags
|
const (
|
||||||
var (
|
toolname = "pt-galera-log-explainer"
|
||||||
version string
|
|
||||||
commit string
|
|
||||||
date string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// We do not set anything here, these variables are defined by the Makefile
|
||||||
|
var (
|
||||||
|
Build string //nolint
|
||||||
|
GoVersion string //nolint
|
||||||
|
Version string //nolint
|
||||||
|
Commit string //nolint
|
||||||
|
)
|
||||||
|
|
||||||
|
var buildInfo = fmt.Sprintf("%s\nVersion %s\nBuild: %s using %s\nCommit: %s\n", toolname, Version, Build, GoVersion, Commit)
|
||||||
|
|
||||||
var CLI struct {
|
var CLI struct {
|
||||||
NoColor bool
|
NoColor bool
|
||||||
Since *time.Time `help:"Only list events after this date, format: 2023-01-23T03:53:40Z (RFC3339)"`
|
Since *time.Time `help:"Only list events after this date, format: 2023-01-23T03:53:40Z (RFC3339)"`
|
||||||
@@ -33,28 +40,22 @@ var CLI struct {
|
|||||||
Sed sed `cmd:""`
|
Sed sed `cmd:""`
|
||||||
Ctx ctx `cmd:""`
|
Ctx ctx `cmd:""`
|
||||||
RegexList regexList `cmd:""`
|
RegexList regexList `cmd:""`
|
||||||
Version versioncmd `cmd:""`
|
|
||||||
Conflicts conflicts `cmd:""`
|
Conflicts conflicts `cmd:""`
|
||||||
|
|
||||||
|
Version kong.VersionFlag
|
||||||
|
|
||||||
GrepCmd string `help:"'grep' command path. Could need to be set to 'ggrep' for darwin systems" default:"grep"`
|
GrepCmd string `help:"'grep' command path. Could need to be set to 'ggrep' for darwin systems" default:"grep"`
|
||||||
GrepArgs string `help:"'grep' arguments. perl regexp (-P) is necessary. -o will break the tool" default:"-P"`
|
GrepArgs string `help:"'grep' arguments. perl regexp (-P) is necessary. -o will break the tool" default:"-P"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type versioncmd struct{}
|
|
||||||
|
|
||||||
func (v *versioncmd) Help() string {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
func (v *versioncmd) Run() error {
|
|
||||||
fmt.Printf("version: %s, commit:%s, built at %s\n", version, commit, date)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx := kong.Parse(&CLI,
|
ctx := kong.Parse(&CLI,
|
||||||
kong.Name("pt-galera-log-explainer"),
|
kong.Name(toolname),
|
||||||
kong.Description("An utility to merge and help analyzing Galera logs"),
|
kong.Description("An utility to merge and help analyzing Galera logs"),
|
||||||
kong.UsageOnError(),
|
kong.UsageOnError(),
|
||||||
|
kong.Vars{
|
||||||
|
"version": buildInfo,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||||
|
Reference in New Issue
Block a user