Skip to content

Commit 97c1e79

Browse files
committed
Set time limit as a command argument
1 parent 4038378 commit 97c1e79

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kadai3-1/lfcd85/cmd/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"flag"
45
"fmt"
56
"time"
67

@@ -10,14 +11,17 @@ import (
1011

1112
func main() {
1213
path := "./testdata/go_standard_library.txt" // FIXME: move to options
14+
timeLimit := flag.Int("t", 30, "Time limit of the game (secs)")
15+
flag.Parse()
16+
1317
words, err := words.Import(path)
1418
if err != nil {
1519
fmt.Println("error:", err)
1620
return
1721
}
1822
g := typinggame.Game{
1923
Words: words,
20-
TimeLimit: 30 * time.Second,
24+
TimeLimit: time.Duration(*timeLimit) * time.Second,
2125
}
2226

2327
if err := typinggame.Execute(g); err != nil {

0 commit comments

Comments
 (0)