-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (41 loc) · 1.08 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"io"
"log"
"os"
"github.com/lucasgpulcinelli/goICMCsim/display"
"net/http"
_ "net/http/pprof"
)
var (
initialCode = flag.String("codemif", "", "code MIF file to use at startup")
initialChar = flag.String("charmif", "", "character MIF file to use at startup")
)
// getFiles reads from the command line flags provided both the initial code MIF
// and initial character mapping MIF, and returns them to the caller.
func getFiles() (codem, charm io.ReadCloser) {
var err error
// parse all the command line flags
flag.Parse()
if *initialCode != "" {
codem, err = os.Open(*initialCode)
if err != nil {
log.Printf("error opening %s: %v\n", *initialCode, err.Error()) // TODO: log -> dialog/logFile
}
}
if *initialChar != "" {
charm, err = os.Open(*initialChar)
if err != nil {
log.Printf("error opening %s: %v\n", *initialChar, err.Error()) // TODO: log -> dialog/logFile
}
}
return
}
func main() {
go func() {
http.ListenAndServe("localhost:6060", nil)
}()
codem, charm := getFiles()
display.StartSimulatorWindow(codem, charm)
}