-
Notifications
You must be signed in to change notification settings - Fork 0
/
nag.go
64 lines (52 loc) · 1.36 KB
/
nag.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
59
60
61
62
63
64
// #! `which go`
// nag - a command-line reminder and timer
// Usage:
// $ nag <integer> [ s|m|h ] [ -m <message> ] [ -s, --quiet ]
// Options:
// time (in [ seconds | minutes | hours ])
// message (optional)
// quiet (do not `say` the command)
package main
import (
"fmt"
"log"
"flag"
"time"
"runtime"
"os/exec"
)
var seconds = flag.Int("sec", 0, "Number of seconds to wait before Nagging.")
var minutes = flag.Int("min", 0, "Number of minutes to wait before Nagging.")
var message = flag.String("msg", "HEY!", "Message to Nag you with.")
var quiet = flag.Bool("quiet", false, "Do not speak the string (Mac Only.)")
var q = flag.Bool("q", false, "No auditory output; Do not speak the string (Mac Only.)")
func speak(m *string) {
if runtime.GOOS == "darwin" {
speak := exec.Command("say", *message)
err := speak.Start()
if err != nil {
log.Fatal(err)
}
}
}
func main() {
flag.Parse()
/*
// Arch Details
fmt.Println("GOARCH: ", runtime.GOARCH)
fmt.Println("GOOS: ", runtime.GOOS)
*/
/*
// Diag
fmt.Println("Nagging in this many seconds: ", *seconds)
fmt.Println("Nagging in this many minutes: ", *minutes)
fmt.Println("Nagging with this message: ", *message)
*/
time.Sleep(time.Duration(*seconds) * time.Second)
time.Sleep(time.Duration(*minutes) * time.Minute)
fmt.Println()
if !*quiet && !*q {
speak(message)
}
fmt.Println(*message)
}