Merge pull request #2 from gmgauthier/versioning_for_gostations

Versioning for gostations
This commit is contained in:
Greg Gauthier 2021-03-18 22:26:55 +00:00 committed by GitHub
commit eb19d5280a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.2

16
build.sh Executable file
View File

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

View File

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