-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsreader.go
More file actions
50 lines (39 loc) · 1.09 KB
/
sreader.go
File metadata and controls
50 lines (39 loc) · 1.09 KB
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
package main
import (
"flag"
"log"
"os"
"github.com/bmoneill/sreader/config"
"github.com/bmoneill/sreader/feed"
"github.com/bmoneill/sreader/ui"
)
func main() {
// Modify default config file path if $XDG_CONFIG_HOME is set
confPath := config.ExpandHome(config.DefaultConfFile)
if xdgConfDir := os.Getenv("XDG_CONFIG_HOME"); xdgConfDir != "" {
confPath = xdgConfDir + "/sreader/config.toml"
}
// Parse command line flags
confFlag := flag.String("c", confPath, "Path to the configuration file")
syncFlag := flag.Bool("s", false, "Sync feeds and exit")
flag.Parse()
config.LoadConfig(*confFlag)
writer, err := os.OpenFile(config.ExpandHome(config.Config.LogFile), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
log.Fatalln("Failed to open or create log file:", err.Error())
}
log.SetOutput(writer)
feed.InitDB()
// sync and quit if called with "-s" flag
if *syncFlag {
feed.Sync()
feed.CloseDB()
return
}
feeds := feed.GetFeeds()
ui := ui.Init(feeds)
if _, err := ui.Run(); err != nil {
log.Fatalln("Failed to start UI", err.Error())
}
feed.CloseDB()
}