Made database cmdline arg optional again, fixed appveyor.yml

This commit is contained in:
Bora Alper 2017-11-15 00:25:32 +00:00
parent b44d56f07d
commit 64ff7e0749
2 changed files with 16 additions and 5 deletions

View File

@ -7,10 +7,10 @@ branches:
- go-rewrite
# Source Config
clone_folder: c:\gopath\src\github.com\boramalper\magnetico
clone_folder: c:\gopath\src\magnetico
shallow_clone: true
# Build host
environment:
GOPATH: c:\gopath
GOVERSION: 1.9.2
@ -25,4 +25,10 @@ install:
- go env
build_script:
- go install github.com/magnetico/magneticod
- go install magnetico/magneticod
- go install magnetico/magneticow
test_script:
- go test -cover magnetico/magneticod/...
- go test -cover magnetico/magneticow/...
- go test -cover magnetico/persistence/...

View File

@ -17,10 +17,12 @@ import (
"magnetico/persistence"
"runtime/pprof"
"github.com/Wessie/appdirs"
"path"
)
type cmdFlags struct {
DatabaseURL string `long:"database" description:"URL of the database." required:"yeah"`
DatabaseURL string `long:"database" description:"URL of the database."`
TrawlerMlAddrs []string `long:"trawler-ml-addr" description:"Address(es) to be used by trawling DHT (Mainline) nodes." default:"0.0.0.0:0"`
TrawlerMlInterval uint `long:"trawler-ml-interval" description:"Trawling interval in integer deciseconds (one tenth of a second)."`
@ -142,7 +144,10 @@ func parseFlags() (*opFlags, error) {
}
if cmdF.DatabaseURL == "" {
zap.S().Fatal("database")
opF.DatabaseURL = "sqlite3://" + path.Join(
appdirs.UserDataDir("magneticod", "", "", false),
"database.sqlite3",
)
} else {
opF.DatabaseURL = cmdF.DatabaseURL
}