-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpaperless.go
48 lines (39 loc) · 904 Bytes
/
paperless.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 (
"fmt"
"os"
"strings"
util "github.com/kopoli/go-util"
"github.com/kopoli/paperless/lib"
)
var (
version = "Undefined"
timestamp = "Undefined"
)
func printErr(err error, message string, arg ...string) {
msg := ""
if err != nil {
msg = fmt.Sprintf(" (error: %s)", err)
}
fmt.Fprintf(os.Stderr, "Error: %s%s.%s\n", message, strings.Join(arg, " "), msg)
}
func fault(err error, message string, arg ...string) {
printErr(err, message, arg...)
os.Exit(1)
}
func main() {
opts := util.NewOptions()
opts.Set("program-name", os.Args[0])
opts.Set("program-version", version)
err := paperless.Cli(opts, os.Args)
if err != nil {
fault(err, "Command line parsing failed")
}
err = paperless.StartWeb(opts)
if err != nil {
fault(err, "Starting paperless web server failed")
}
}
// Local Variables:
// outline-regexp: "^////*\\|^func\\|^import"
// End: