add a makeshift versioning for the executable to distinguish each build
This commit is contained in:
		
							parent
							
								
									8df21e59b0
								
							
						
					
					
						commit
						702edbc7a4
					
				
							
								
								
									
										10
									
								
								build.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								build.sh
									
									
									
									
									
										Normal file
									
								
							@ -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"
 | 
				
			||||||
							
								
								
									
										16
									
								
								stations.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								stations.go
									
									
									
									
									
								
							@ -6,6 +6,12 @@ import (
 | 
				
			|||||||
	"os"
 | 
						"os"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var version float32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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(¬ok, "x", false,"If toggled, will show stations that are down")
 | 
						flag.BoolVar(¬ok, "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)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user