mirror of
https://codeberg.org/scip/golsky.git
synced 2025-12-16 20:20:57 +01:00
print version from main
This commit is contained in:
11
config.go
11
config.go
@@ -3,12 +3,12 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/tlinden/golsky/rle"
|
||||
)
|
||||
|
||||
// all the settings comming from commandline, but maybe tweaked later from the UI
|
||||
type Config struct {
|
||||
Width, Height, Cellsize, Density int // measurements
|
||||
ScreenWidth, ScreenHeight int
|
||||
@@ -20,12 +20,12 @@ type Config struct {
|
||||
Statefile string // load game state from it if non-nil
|
||||
StateGrid *Grid // a grid from a statefile
|
||||
Wrap bool // wether wraparound mode is in place or not
|
||||
ShowVersion bool
|
||||
}
|
||||
|
||||
func ParseCommandline() *Config {
|
||||
config := Config{}
|
||||
|
||||
showversion := false
|
||||
var rule string
|
||||
var rlefile string
|
||||
|
||||
@@ -41,7 +41,7 @@ func ParseCommandline() *Config {
|
||||
pflag.StringVarP(&rlefile, "rle-file", "f", "", "RLE pattern file")
|
||||
pflag.StringVarP(&config.Statefile, "load-state-file", "l", "", "game state file")
|
||||
|
||||
pflag.BoolVarP(&showversion, "version", "v", false, "show version")
|
||||
pflag.BoolVarP(&config.ShowVersion, "version", "v", false, "show version")
|
||||
pflag.BoolVarP(&config.Paused, "paused", "p", false, "do not start simulation (use space to start)")
|
||||
pflag.BoolVarP(&config.Debug, "debug", "d", false, "show debug info")
|
||||
pflag.BoolVarP(&config.NoGrid, "nogrid", "n", false, "do not draw grid lines")
|
||||
@@ -52,11 +52,6 @@ func ParseCommandline() *Config {
|
||||
|
||||
pflag.Parse()
|
||||
|
||||
if showversion {
|
||||
fmt.Printf("This is golsky version %s\n", VERSION)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// check if we have been given an RLE file to load
|
||||
config.RLE = GetRLE(rlefile)
|
||||
if config.RLE != nil {
|
||||
|
||||
6
main.go
6
main.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -36,6 +37,11 @@ func GetRLE(filename string) *rle.RLE {
|
||||
func main() {
|
||||
config := ParseCommandline()
|
||||
|
||||
if config.ShowVersion {
|
||||
fmt.Printf("This is golsky version %s\n", VERSION)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
game := NewGame(config, Play)
|
||||
|
||||
// setup environment
|
||||
|
||||
Reference in New Issue
Block a user