From b6564ddd6313e0b17c7dd93571d32b61da932e15 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 2 Oct 2023 13:12:28 -0600 Subject: [PATCH] Restore version info --- .goreleaser.yml | 2 +- cmd/gpq/command/version.go | 18 +++++++++--------- cmd/gpq/main.go | 8 +++++++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 745b719..7fc0934 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -60,4 +60,4 @@ brews: description: "Utility for working with GeoParquet." license: "Apache-2.0" test: | - system "#{bin}/xyz2ogc version" + system "#{bin}/gpq version" diff --git a/cmd/gpq/command/version.go b/cmd/gpq/command/version.go index a0fb6e0..4e36ee9 100644 --- a/cmd/gpq/command/version.go +++ b/cmd/gpq/command/version.go @@ -16,20 +16,20 @@ package command import "fmt" -var ( - version = "dev" - commit = "none" - date = "unknown" -) - type VersionCmd struct { Detail bool `help:"Include detail about the commit and build date."` } -func (c *VersionCmd) Run() error { - output := version +type VersionInfo struct { + Version string + Commit string + Date string +} + +func (c *VersionCmd) Run(info *VersionInfo) error { + output := info.Version if c.Detail { - output = fmt.Sprintf("%s (%s %s)", output, commit, date) + output = fmt.Sprintf("%s (%s %s)", output, info.Commit, info.Date) } fmt.Println(output) return nil diff --git a/cmd/gpq/main.go b/cmd/gpq/main.go index 9476038..51d4b39 100644 --- a/cmd/gpq/main.go +++ b/cmd/gpq/main.go @@ -19,8 +19,14 @@ import ( "github.com/planetlabs/gpq/cmd/gpq/command" ) +var ( + version = "dev" + commit = "none" + date = "unknown" +) + func main() { ctx := kong.Parse(&command.CLI) - err := ctx.Run(ctx) + err := ctx.Run(ctx, &command.VersionInfo{Version: version, Commit: commit, Date: date}) ctx.FatalIfErrorf(err) }