-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (33 loc) · 781 Bytes
/
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
package main
import (
"os"
"github.com/nenad/couch/cmd"
"github.com/nenad/couch/pkg/config"
"github.com/nenad/couch/pkg/storage"
"github.com/sirupsen/logrus"
)
func main() {
var dbName = os.Getenv("COUCH_DB")
if dbName == "" {
dbName = "couch.sqlite"
}
db, err := storage.NewCouchDatabase(dbName)
if err != nil {
logrus.Errorf("error while creating a database: %s", err)
os.Exit(1)
}
store := &config.Store{DB: db}
conf, err := config.InitConfiguration(store)
if err != nil {
if err := store.Save(conf); err != nil {
logrus.Errorf("error while saving initial config: %s", err)
os.Exit(1)
}
}
rootCmd := cmd.NewCLI(conf, db)
err = rootCmd.Execute()
if err != nil {
logrus.Errorf("error while executing command: %s", err)
os.Exit(1)
}
}