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 - go-rewrite
# Source Config # Source Config
clone_folder: c:\gopath\src\github.com\boramalper\magnetico clone_folder: c:\gopath\src\magnetico
shallow_clone: true
# Build host # Build host
environment: environment:
GOPATH: c:\gopath GOPATH: c:\gopath
GOVERSION: 1.9.2 GOVERSION: 1.9.2
@ -25,4 +25,10 @@ install:
- go env - go env
build_script: 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" "magnetico/persistence"
"runtime/pprof" "runtime/pprof"
"github.com/Wessie/appdirs"
"path"
) )
type cmdFlags struct { 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"` 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)."` 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 == "" { if cmdF.DatabaseURL == "" {
zap.S().Fatal("database") opF.DatabaseURL = "sqlite3://" + path.Join(
appdirs.UserDataDir("magneticod", "", "", false),
"database.sqlite3",
)
} else { } else {
opF.DatabaseURL = cmdF.DatabaseURL opF.DatabaseURL = cmdF.DatabaseURL
} }