-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
48 lines (42 loc) · 1000 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
package main
import (
"flag"
"fmt"
"os"
"time"
cmd "github.com/skatkov/stoic/cmd"
stoic "github.com/skatkov/stoic/internal"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
ctx := stoic.NewContext(
os.Getenv("STOIC_DIR"),
os.Getenv("STOIC_EXT"),
os.Getenv("EDITOR"),
os.Getenv("STOIC_TEMPLATE"),
)
aboutFlag := flag.Bool("about", false, "display about info")
listFlag := flag.Bool("list", false, "list journal entries")
quoteFlag := flag.Bool("quote", false, "random quote to inspire ongoing journaling habit")
editFlag := flag.String("edit", "", "edit a journal entry")
flag.Parse()
switch {
case *aboutFlag:
cmd.NewAboutCommand(version, commit, date).Run()
case *listFlag:
cmd.NewListCommand(ctx).Run()
case *editFlag != "":
cmd.NewEditCommand(ctx, *editFlag).Run()
case *quoteFlag:
cmd.NewQuoteCommand().Run()
default:
err := ctx.OpenInEditor(stoic.NewEntry(ctx, time.Now()))
if err != nil {
fmt.Println(err)
}
}
}