aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2021-05-04 17:08:33 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2021-05-04 17:08:33 +0100
commit47415cc7e9ff17016264982ce3d7de3fd907dba7 (patch)
tree55bf003294f1669a74dfaa995371582e76a6c1b7 /cmd
parent4457cd61f10565c5fa1abafc5e763fb676c4293f (diff)
fixed problem of repeating Setup() procedure
Diffstat (limited to 'cmd')
-rw-r--r--cmd/datamaps/main.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/cmd/datamaps/main.go b/cmd/datamaps/main.go
index e9e34f6..5cfc4f4 100644
--- a/cmd/datamaps/main.go
+++ b/cmd/datamaps/main.go
@@ -17,11 +17,18 @@ func main() {
os.Stdout.WriteString(datamaps.Usage)
os.Exit(0)
}
- dbpc := datamaps.NewDBPathChecker(os.UserConfigDir)
- if !dbpc.Check() {
- datamaps.SetUp()
- }
+ // TODO - removed this to handle "setup" bug below.
+ // Check that removing this has no consequences.
+ // dbpc := datamaps.NewDBPathChecker(os.UserConfigDir)
+ // if !dbpc.Check() {
+ // datamaps.SetUp()
+ // }
switch opts.Command {
+ case "checkdb":
+ dbpc := datamaps.NewDBPathChecker(os.UserConfigDir)
+ if !dbpc.Check() {
+ log.Println("No database file exists. Please run datamaps setup")
+ }
case "import":
if err := datamaps.ImportToDB(opts); err != nil {
log.Fatal(err)
@@ -31,6 +38,8 @@ func main() {
log.Fatal(err)
}
case "setup":
+ // BUG This gets called twice if the !dbpc.Check()
+ // call above reveals that the config dir is present
_, err := datamaps.SetUp()
if err != nil {
log.Fatal(err)