Merge pull request #2 from gmgauthier/versioning_for_gostations
Versioning for gostations
This commit is contained in:
		
						commit
						eb19d5280a
					
				
							
								
								
									
										16
									
								
								build.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								build.sh
									
									
									
									
									
										Executable 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"
 | 
			
		||||
							
								
								
									
										16
									
								
								stations.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								stations.go
									
									
									
									
									
								
							@ -6,6 +6,12 @@ import (
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var version string
 | 
			
		||||
 | 
			
		||||
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(¬ok, "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…
	
		Reference in New Issue
	
	Block a user