aboutsummaryrefslogtreecommitdiff
path: root/goffel.go
blob: a6efeb75c18e23c99d5dfca34fbddeec73d4613d (plain)
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
package main

import (
	"flag"
	"math/rand"
	"time"

	"muhq.space/go/muhq/goffel/logic"
	"muhq.space/go/muhq/goffel/uis"
	"muhq.space/go/muhq/goffel/net"
)

var (
	port     string
	server   bool
	greeting string
	client   bool
	fancy    bool
)

func main() {
	rand.Seed(time.Now().Unix())

	flag.StringVar(&port, "p", "1337", "port to listen for connections")
	flag.BoolVar(&server, "s", false, "start a goffel server")
	flag.StringVar(&greeting, "g", "", "Welcome message")
	flag.BoolVar(&client, "c", false, "start a goffel client")
	flag.BoolVar(&fancy, "f", false, "print utf8 dice runes")
	flag.Parse()

	logic.SetFancyPrint(fancy)

	if server {
		s := net.NewServer(port, greeting)
		s.Serve()
	} else if client {
		c := net.Client{Port: port}
		c.Run()
	} else {
		i := uis.Interactive{}
		i.Run()
	}
}