shiori/main.go

38 lines
732 B
Go
Raw Normal View History

2019-05-27 18:01:53 +08:00
//go:generate go run assets-generator.go
2018-01-26 18:40:01 +08:00
package main
2019-05-21 11:31:40 +08:00
import (
2019-05-22 00:24:11 +08:00
"os"
fp "path/filepath"
2019-05-21 11:31:40 +08:00
"github.com/go-shiori/shiori/internal/cmd"
2019-05-22 00:24:11 +08:00
"github.com/go-shiori/shiori/internal/database"
_ "github.com/mattn/go-sqlite3"
2019-05-21 11:31:40 +08:00
"github.com/sirupsen/logrus"
2019-05-27 18:01:53 +08:00
// Add this to prevent it removed by go mod tidy
_ "github.com/shurcooL/vfsgen"
2019-05-21 11:31:40 +08:00
)
2019-05-22 00:24:11 +08:00
var dataDir = "dev-data"
func main() {
2019-05-22 00:24:11 +08:00
// Make sure data dir exists
os.MkdirAll(dataDir, os.ModePerm)
// Open database
dbPath := fp.Join(dataDir, "shiori.db")
sqliteDB, err := database.OpenSQLiteDatabase(dbPath)
if err != nil {
logrus.Fatalln(err)
}
// Execute cmd
cmd.DB = sqliteDB
cmd.DataDir = dataDir
if err := cmd.ShioriCmd().Execute(); err != nil {
2019-05-21 11:31:40 +08:00
logrus.Fatalln(err)
}
2018-03-05 08:14:58 +08:00
}