Skip to content

Commit

Permalink
Merge pull request #85 from planetlabs/version
Browse files Browse the repository at this point in the history
Restore version info
  • Loading branch information
tschaub authored Oct 2, 2023
2 parents dd967c7 + b6564dd commit c463b58
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ brews:
description: "Utility for working with GeoParquet."
license: "Apache-2.0"
test: |
system "#{bin}/xyz2ogc version"
system "#{bin}/gpq version"
18 changes: 9 additions & 9 deletions cmd/gpq/command/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion cmd/gpq/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit c463b58

Please sign in to comment.