add a makeshift versioning for the executable to distinguish each build

versioning_for_gostations
Greg Gauthier 2 years ago
parent 8df21e59b0
commit 702edbc7a4
  1. 1
      VERSION
  2. 10
      build.sh
  3. 16
      stations.go

@ -0,0 +1 @@
0.2

@ -0,0 +1,10 @@
#!/usr/bin/env sh
# shellcheck disable=SC2155
export GIT_COMMIT=$(git rev-list -1 HEAD)
CANONICAL_VERSION=$(cat ./VERSION)
VERSION_STRING="$CANONICAL_VERSION ($GIT_COMMIT)"
go mod vendor
go mod tidy
go build -o build/gostations -ldflags "-X main.version=$VERSION_STRING"

@ -6,6 +6,12 @@ import (
"os"
)
var version float32
func showVersion(){
fmt.Println(version)
}
func precheck(){
if !isInstalled(player()){
fmt.Printf("%s is either not installed, or not on your $PATH. Cannot continue.\n", player())
@ -22,11 +28,12 @@ func main(){
state string
tags string
notok bool
version bool
)
flag.Usage = func() {
fmt.Printf("Usage: \n")
fmt.Printf(" gostations ")
fmt.Printf(" [-n \"name\"] [-c \"home country\"] [-s \"home state\"] [-t \"ordered,tag,list\"] [-x]\n")
fmt.Printf(" [-n \"name\"] [-c \"home country\"] [-s \"home state\"] [-t \"ordered,tag,list\"] [-x] [-v]\n")
flag.PrintDefaults()
fmt.Printf(" -h (or none)\n")
fmt.Printf("\tThis help message\n")
@ -36,12 +43,19 @@ func main(){
flag.StringVar(&state, "s", "", "Home state (if in the United States).")
flag.StringVar(&tags, "t", "", "Tag (or comma-separated tag list)")
flag.BoolVar(&notok, "x", false,"If toggled, will show stations that are down")
flag.BoolVar(&version, "v", false, "Show version.")
flag.Parse()
if argCount == 0 {
flag.Usage()
os.Exit(0)
}
if version {
showVersion()
os.Exit(0)
}
precheck()
stations, _ := StationSearch(name, country, state, tags, notok)

Loading…
Cancel
Save