forked from lcarva/festoji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (42 loc) · 993 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
50
51
package main
import (
"flag"
"fmt"
"log"
"os"
"strings"
"time"
"github.com/lcarva/festoji/app"
)
var (
n = flag.Int("n", 1, "number of characters/days to display")
day = flag.Bool("day", false, "display day for the character")
rule = flag.Bool("rule", false, "display matching rule for the character")
)
func main() {
flag.Parse()
userConfigPath := os.ExpandEnv("${HOME}/.festoji.yaml")
config, errConfig := app.NewConfig(userConfigPath)
if errConfig != nil {
log.Fatal("Unable to load configuration: ", errConfig)
return
}
t := time.Now()
for i := 0; i < *n; i++ {
character, ruleName, errChar := app.Character(t, config)
if errChar != nil {
log.Fatal("Unable to get character: ", errChar)
return
}
var parts []string
if *day {
parts = append(parts, t.Format("02/Jan/2006"))
}
parts = append(parts, character)
if *rule {
parts = append(parts, ruleName)
}
fmt.Println(strings.Join(parts, " "))
t = t.Add(time.Hour * 24)
}
}