-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflags.go
More file actions
137 lines (127 loc) · 6.65 KB
/
flags.go
File metadata and controls
137 lines (127 loc) · 6.65 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package main
import (
"flag"
//"strconv"
"os"
)
var (
flags struct {
dbName string // Database name, currently 'votezilla'.
dbUser string // Database user.
dbPassword string // Database password.
dbSalt string // Salt for encrypting secure information in database.
debug string // Reloads template files every time
secureCookieHashKey string // Secure key for encrypting secure cookies.
secureCookieBlockKey string // Even more secure key for encrypting secure cookies.
newsAPIKey string // News API key.
//printMask PrintMask // For selective logging.
port string // Which port to serve webpages from.
offlineNews string // Whether to use offline cached news, when working without Internet connection.
newsService string // Whether to be the news service.
imageService string // Whether to be the image service.
test string // Whether to run a simple test, instead of the actual service.
mode string // A special mode to run a service in.
testUserId string // UserId to test being loggin in as.
isNewsAccelerated string // Whether News API queries should be accelerated.
randomizeTime string
skipWhitelist bool
domain string
cachingService string // Whether to be the caching service.
requirePassword bool // Whether to require passwords for logging in.
checkForNotifications bool // Whether to do ajaxCheckForNotifications
separateNewsAndPolls bool // Whether to separate news and polls in separate tabs
skipFirewall bool // Whether to skip the firewall
testEmail bool // Send a test email and exit
dailyEmail bool // Send the daily email and exit
smtpServer string // SMTP Server
smtpUsername string //
smtpPassword string //
dryRun bool // If true, email message is generated but not sent
featuredArticleId string // For the daily poll email, the main article (i.e. poll) to share.")
emailTarget string // Target for the batch email, e.g. 'Daily', 'Test', one day... 'Weekly' and 'Monthly'
testEmailAddress string // Test email address
emailSubject string // Subject for the email
newSubs string
customEmails string
businessEmail string
mapsApiKey string
mapsAutoComplete bool
}
)
///////////////////////////////////////////////////////////////////////////////
//
// flags
//
///////////////////////////////////////////////////////////////////////////////
func parseCommandLineFlags() {
// Grab command line flags
f1 := flag.String("dbname", "vz", "Database to connect to")
f2 := flag.String("dbuser", "", "Database user")
f3 := flag.String("dbpassword", "", "Database password")
f4 := flag.String("dbsalt", "SALT", "Database salt (for security)")
f5 := flag.String("debug", "", "debug=true for development")
f6 := flag.String("cookieHashKey", "very-secret", "secure cookie hash key")
f7 := flag.String("cookieBlockKey", "a-lot-secret", "secure cookie block key")
f8 := flag.String("newsAPIKey", "", "news API key from https://newsapi.org")
//f9 := flag.String("printMask", "65535", "log output mask")
fa := flag.String("port", "8080", "which port to serve webpages from")
fb := flag.String("offlineNews", "", "whether to use offline news")
fc := flag.String("newsService", "", "whether to be the news service")
fd := flag.String("imageService", "", "whether to be the image service")
fe := flag.String("test", "", "whether to run a simple test, instead of the actual server")
ff := flag.String("mode", "", "a special mode to run a server in")
fg := flag.String("testUserId", "", "UserId to test being loggin in as")
fh := flag.String("isNewsAccelerated", "", "Whether News API queries should be accelerated")
fi := flag.String("randomizeTime", "true", "True to randomize article order a little, in /news.")
fj := flag.String("cachingService", "", "whether to be the caching service")
flag.BoolVar(&flags.skipWhitelist, "skipWhitelist", false, "skip reading the whitelist, which is slow")
flag.StringVar(&flags.domain, "domain", "", "domain name to request your certificate")
flag.BoolVar(&flags.requirePassword, "requirePassword", false, "Whether to require passwords for logging in.")
flag.BoolVar(&flags.checkForNotifications, "checkForNotifications", true, "Whether to do ajaxCheckForNotifications.")
flag.BoolVar(&flags.separateNewsAndPolls, "separateNewsAndPolls", false, "Whether to separate news and polls in separate tabs.")
flag.BoolVar(&flags.skipFirewall, "skipFirewall", true, "Whether to skip the firewall")
flag.BoolVar(&flags.testEmail, "testEmail", false, "Send a test email and exit")
flag.BoolVar(&flags.dailyEmail, "dailyEmail", false, "Send the daily email and exit")
flag.StringVar(&flags.businessEmail, "businessEmail", "", "")
flag.StringVar(&flags.smtpServer, "smtpServer", "", "")
flag.StringVar(&flags.smtpUsername, "smtpUsername", "", "")
flag.StringVar(&flags.smtpPassword, "smtpPassword", "", "Password for sending email to the SMTP server")
flag.BoolVar(&flags.dryRun, "dryRun", true, "If true, email message is generated but not sent")
flag.StringVar(&flags.featuredArticleId, "featuredArticleId", "-1", "For the daily poll email, the main article (i.e. poll) to share, or a comma-separated list.")
flag.StringVar(&flags.emailTarget, "emailTarget", "", "Target for the batch email, e.g. 'Daily', 'Test', 'newSubs', one day... 'Weekly' and 'Monthly'")
flag.StringVar(&flags.testEmailAddress, "testEmailAddress", "", "Test email address")
flag.StringVar(&flags.emailSubject, "emailSubject", "", "Subject for the email")
flag.StringVar(&flags.customEmails, "customEmails", "", "Custom email list to send to")
flag.StringVar(&flags.newSubs, "newSubs", "", "Newsletter subscribers (who are not yet uers) - comma-separated email list")
flag.StringVar(&flags.mapsApiKey, "mapsApiKey", "", "Maps Api Key")
flag.BoolVar(&flags.mapsAutoComplete, "mapsAutoComplete", false, "Maps Auto-complete")
prVal("Command Line Args", os.Args)
flag.Parse()
flags.dbName = *f1
flags.dbUser = *f2
flags.dbPassword = *f3
flags.dbSalt = *f4
flags.debug = *f5
flags.secureCookieHashKey = *f6
flags.secureCookieBlockKey = *f7
flags.newsAPIKey = *f8
/*
printMask, err := strconv.Atoi(*f9)
flags.printMask = PrintMask(printMask)
if err != nil {
flags.printMask = PrintMask(all_)
}
*/
flags.port = *fa
flags.offlineNews = *fb
flags.newsService = *fc
flags.imageService = *fd
flags.test = *fe
flags.mode = *ff
flags.mode = *ff
flags.testUserId = *fg
flags.isNewsAccelerated = *fh
flags.randomizeTime = *fi
flags.cachingService = *fj
prf("flags: %#v\n", flags)
}