From 0bb739c8333c7101cb60812bf1fd3c40b283a5f5 Mon Sep 17 00:00:00 2001 From: Guido Zuidhof Date: Tue, 16 Apr 2024 18:24:17 +0200 Subject: [PATCH] Use version flag --- buildinfo/buildinfo.go | 2 +- cmd/cli.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/buildinfo/buildinfo.go b/buildinfo/buildinfo.go index 661f026..96db014 100644 --- a/buildinfo/buildinfo.go +++ b/buildinfo/buildinfo.go @@ -34,7 +34,7 @@ func Commit() string { } // Target returns the target operating system that this binary was compiled for, -// or "" if it is not set. This is injected by goreleaser. +// or "" if it is not set. func Target() string { return runtime.GOOS } diff --git a/cmd/cli.go b/cmd/cli.go index ac79512..1028fa6 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -23,7 +23,7 @@ type Config struct { File string `help:"Path to read response from." short:"f" default:"agentstate"` } `cmd:"" help:"Start hareply TCP responder service."` - Version struct{} `cmd:"" help:"Show version information."` + Version kong.VersionFlag } // CLI runs the hareply CLI. @@ -34,6 +34,7 @@ func CLI(ctx context.Context, w io.Writer, args []string, opts ...kong.Option) e kong.Name("hareply"), kong.Description("A simple TCP server that replies with a response read from a file."), kong.DefaultEnvars("HAREPLY_"), + kong.Vars{"version": buildinfo.FullVersion()}, ) kcli, err := kong.New(&cli, opts...)