-
Notifications
You must be signed in to change notification settings - Fork 218
/
watch.go
34 lines (31 loc) · 703 Bytes
/
watch.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
package cmd
import (
"strings"
"github.com/xalanq/cf-tool/client"
"github.com/xalanq/cf-tool/config"
)
// Watch command
func Watch(args map[string]interface{}) error {
contestID, err := getContestID(args)
if err != nil {
return err
}
problemID, _ := args["<problem-id>"].(string)
problemID = strings.ToLower(problemID)
cfg := config.New(config.ConfigPath)
cln := client.New(config.SessionPath)
n := 10
if args["all"].(bool) {
n = -1
}
_, err = cln.WatchSubmission(contestID, problemID, n, false)
if err != nil {
if err = loginAgain(cfg, cln, err); err == nil {
_, err = cln.WatchSubmission(contestID, problemID, n, false)
}
}
if err != nil {
return err
}
return nil
}