forked from disintegration/bebop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (45 loc) · 1.31 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
// Bebop is a simple discussion board / forum web application.
// The bebop command is a command-line tool that manages the bebop web server.
package main
import (
"flag"
"fmt"
"log"
"os"
)
var (
logger = log.New(os.Stdout, "", log.LstdFlags|log.LUTC)
useEnvConfig = flag.Bool("e", false, "use environment variables as config")
)
func main() {
flag.Usage = help
flag.Parse()
cmds := map[string]func(){
"start": startServer,
"init": initConfig,
"gen-key": genKey,
"admins": printAdmins,
"add-admin": addAdmin,
"remove-admin": removeAdmin,
"help": help,
}
if cmdFunc, ok := cmds[flag.Arg(0)]; ok {
cmdFunc()
} else {
help()
os.Exit(2)
}
}
func help() {
fmt.Fprintln(os.Stderr, `Usage:
bebop start - start the server
bebop init - create an initial configuration file
bebop gen-key - generate a random 32-byte hex-encoded key
bebop admins - show the admin list
bebop add-admin <username> - add a user to the admin list
bebop remove-admin <username> - remove a user from the admin list
bebop help - show this message
Use -e flag to read configuration from environment variables instead of a file. E.g.:
bebop -e start
bebop -e admins`)
}