-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (43 loc) · 1000 Bytes
/
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
49
package main
import (
"fmt"
"interview-mali8/client"
"interview-mali8/server"
"os"
"strconv"
)
func main() {
if len(os.Args) > 1 {
switch ok := os.Args[1]; ok {
case "server":
server.Server()
case "client":
if len(os.Args) < 3 {
fmt.Printf("\n Provide client argument! \n")
printUsage()
break
}
numberOfClients, err := strconv.Atoi(os.Args[2])
if err != nil {
fmt.Printf("\n Provide client argument as whole number! \n")
printUsage()
break
}
client.Client(numberOfClients)
case "help":
printUsage()
default:
printUsage()
}
} else {
printUsage()
}
}
func printUsage() {
fmt.Printf("\n Usage: \n\n \t interview-mali8 command [arguments]")
fmt.Printf("\n\n The commands are: \n")
fmt.Printf("\n \t server \t\t run HTTP Denial-of-Service protection system on port 8080")
fmt.Printf("\n \t client [clientNum] \t run clientNum of HTTP clients")
fmt.Printf("\n \t help \t\t\t print usage instructions")
fmt.Printf("\n")
}