-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathttimer.go
58 lines (49 loc) · 925 Bytes
/
ttimer.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
50
51
52
53
54
55
56
57
58
package main
import (
"fmt"
"os"
"github.com/drgrib/ttimer/agent"
"github.com/drgrib/ttimer/parse"
)
//////////////////////////////////////////////
/// flags
//////////////////////////////////////////////
var args struct {
t string
q bool
}
func init() {
switch len(os.Args) {
case 3:
if os.Args[1] == "-q" {
args.q = true
args.t = os.Args[2]
}
if os.Args[2] == "-q" {
args.q = true
args.t = os.Args[1]
}
case 2:
args.t = os.Args[1]
default:
args.t = "1m"
}
}
//////////////////////////////////////////////
/// main
//////////////////////////////////////////////
func main() {
// parse
d, title, err := parse.Args(args.t)
if err != nil {
fmt.Println(err.Error())
fmt.Println("\nPlease refer to https://github.com/drgrib/ttimer for usage instructions.")
return
}
// start timer
t := agent.Timer{Title: title}
t.AutoQuit = args.q
t.Start(d)
// run UI
t.CountDown()
}