Skip to content

Commit

Permalink
add -version flag and disply in help output (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobertlo authored Dec 6, 2024
1 parent c5d3d03 commit 3fcfd4d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/vmars
/gmars
/compile_test
/vmars.exe
/gmars.exe
/compile_test.exe
18 changes: 18 additions & 0 deletions cmd/gmars/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ import (
"github.com/bobertlo/gmars"
)

const (
usage = `gMARS %s
Usage: gmars [options] [warrior1.red] [warrior2.red]
`
)

func main() {
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), usage, "v0.1.14")
flag.PrintDefaults()
}

use88Flag := flag.Bool("8", false, "Enforce ICWS'88 rules")
sizeFlag := flag.Int("s", 8000, "Size of core")
procFlag := flag.Int("p", 8000, "Max. Processes")
Expand All @@ -20,8 +32,14 @@ func main() {
debugFlag := flag.Bool("debug", false, "Dump verbose reporting of simulator state")
assembleFlag := flag.Bool("A", false, "Assemble and output warriors only")
presetFlag := flag.String("preset", "", "Load named preset config (and ignore other flags)")
versionFlag := flag.Bool("version", false, "Print version and exit")
flag.Parse()

if *versionFlag {
fmt.Printf("gMARS %s\n", "v0.1.14")
os.Exit(0)
}

var config gmars.SimulatorConfig
if *presetFlag != "" {
presetConfig, err := gmars.PresetConfig(*presetFlag)
Expand Down
20 changes: 20 additions & 0 deletions cmd/vmars/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ const (
defaultSpeedStep = 6
)

const (
usage = `vMARS %s
Usage: vmars [options] [warrior1.red] [warrior2.red]
`
)

var (
mplusFaceSource *text.GoTextFaceSource

Expand Down Expand Up @@ -53,6 +60,13 @@ func init() {
}

func main() {

flag.Usage = func() {
// fmt.
fmt.Fprintf(flag.CommandLine.Output(), usage, "v0.1.14")
flag.PrintDefaults()
}

use88Flag := flag.Bool("8", false, "Enforce ICWS'88 rules")
sizeFlag := flag.Int("s", 8000, "Size of core")
procFlag := flag.Int("p", 8000, "Max. Processes")
Expand All @@ -63,8 +77,14 @@ func main() {
showReadFlag := flag.Bool("showread", false, "display reads in the visualizer")
debugFlag := flag.Bool("debug", false, "Dump verbose reporting of simulator state")
presetFlag := flag.String("preset", "", "Load named preset config (and ignore other flags)")
versionFlag := flag.Bool("version", false, "Print version and exit")
flag.Parse()

if *versionFlag {
fmt.Printf("vMARS %s\n", "v0.1.14")
os.Exit(0)
}

var config gmars.SimulatorConfig
if *presetFlag != "" {
presetConfig, err := gmars.PresetConfig(*presetFlag)
Expand Down

0 comments on commit 3fcfd4d

Please sign in to comment.