mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-19 18:34:59 +00:00
Fix: --version formatting
This commit is contained in:
@@ -12,13 +12,20 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// ldflags
|
||||
var (
|
||||
version string
|
||||
commit string
|
||||
date string
|
||||
const (
|
||||
toolname = "pt-galera-log-explainer"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
NoColor bool
|
||||
Since *time.Time `help:"Only list events after this date, format: 2023-01-23T03:53:40Z (RFC3339)"`
|
||||
@@ -28,33 +35,27 @@ var CLI struct {
|
||||
ExcludeRegexes []string `help:"Remove regexes from analysis. List regexes using 'pt-galera-log-explainer regex-list'"`
|
||||
MergeByDirectory bool `help:"Instead of relying on identification, merge contexts and columns by base directory. Very useful when dealing with many small logs organized per directories."`
|
||||
|
||||
List list `cmd:""`
|
||||
Whois whois `cmd:""`
|
||||
Sed sed `cmd:""`
|
||||
Ctx ctx `cmd:""`
|
||||
RegexList regexList `cmd:""`
|
||||
Version versioncmd `cmd:""`
|
||||
Conflicts conflicts `cmd:""`
|
||||
List list `cmd:""`
|
||||
Whois whois `cmd:""`
|
||||
Sed sed `cmd:""`
|
||||
Ctx ctx `cmd:""`
|
||||
RegexList regexList `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"`
|
||||
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() {
|
||||
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.UsageOnError(),
|
||||
kong.Vars{
|
||||
"version": buildInfo,
|
||||
},
|
||||
)
|
||||
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||
|
Reference in New Issue
Block a user