-
Notifications
You must be signed in to change notification settings - Fork 3
/
chat.go
33 lines (28 loc) · 876 Bytes
/
chat.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
package main
import (
"github.com/brown-csci1380/whatsup/client"
"github.com/brown-csci1380/whatsup/server"
"flag"
"fmt"
)
func main() {
isServerPtr := flag.Bool("server", false, "run as a server?")
isClientPtr := flag.Bool("client", false, "run as a client?")
userPtr := flag.String("user", "", "username used for this chat client")
serverPortPtr := flag.String("port", "", "chat server port to connect to")
serverAddrPtr := flag.String("addr", "", "address to chat server")
flag.Parse()
if *isClientPtr && *isServerPtr {
fmt.Println("Please rerun with only one: -server or -client")
return
}
if *isServerPtr {
fmt.Println("Starting server")
server.Start()
} else if *isClientPtr {
fmt.Println("Starting client")
client.Start(*userPtr, *serverPortPtr, *serverAddrPtr)
} else {
fmt.Println("Please rerun with either -server or -client")
}
}