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