/
main.go
107 lines (99 loc) · 2.64 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package main
import (
"fmt"
"os"
"github.com/kris-nova/thenovadiary"
"github.com/urfave/cli"
"github.com/kris-nova/logger"
)
func GetApp() *cli.App {
app := &cli.App{
Name: "DiaryApplication",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "puser",
Value: "admin",
Usage: "Used to pass a Photoprism sername at runtime.",
Destination: &DiaryConfig.PhotoprismUser,
},
&cli.StringFlag{
Name: "ppass",
Value: "",
Usage: "Used to pass a Photoprism password secret at runtime.",
Destination: &DiaryConfig.PhotoprismPass,
},
&cli.StringFlag{
Name: "pconn",
Value: "",
Usage: "Used to pass a Photoprism connection string at runtime.",
Destination: &DiaryConfig.PhotoprismConn,
},
&cli.StringFlag{
Name: "palbum",
Value: "",
Usage: "Used to pass a Photoprism album id at runtime.",
Destination: &DiaryConfig.PhotoprismAlbum,
},
&cli.StringFlag{
Name: "twtokensecret",
Value: "",
Usage: "Used to pass a Twitter token secret at runtime.",
Destination: &DiaryConfig.TwitterTokenSecret,
},
&cli.StringFlag{
Name: "twtoken",
Value: "",
Usage: "Used to pass a Twitter token at runtime.",
Destination: &DiaryConfig.TwitterToken,
},
&cli.StringFlag{
Name: "twconsumersecret",
Value: "",
Usage: "Used to pass a Twitter consumer key secret at runtime.",
Destination: &DiaryConfig.TwitterConsumerKeySecret,
},
&cli.StringFlag{
Name: "twconsumer",
Value: "",
Usage: "Used to pass a Twitter consumer key at runtime.",
Destination: &DiaryConfig.TwitterConsumerKey,
},
&cli.StringFlag{
Name: "name",
Value: "Nova",
Usage: "A unique name for this particular set of actions.",
Destination: &DiaryConfig.Name,
},
&cli.IntFlag{
Name: "verbose",
Value: 4,
Usage: "Log level (nova logger)",
Destination: &logger.Level,
},
},
Action: func(c *cli.Context) error {
return RunDiary(DiaryConfig)
},
}
return app
}
func main() {
app := GetApp()
err := app.Run(os.Args)
if err != nil {
logger.Critical("Error running application: %v", err.Error())
}
}
var DiaryConfig = &thenovadiary.DiaryConfig{
//
}
func RunDiary(cfg *thenovadiary.DiaryConfig) error {
err := thenovadiary.ValidateConfig(cfg)
if err != nil {
return fmt.Errorf("Unable to init config: %v", err)
}
logger.Always("Running Diary Program [%s]", cfg.Name)
// Start program here!
app := thenovadiary.New(cfg)
return app.Service()
}