From 47415cc7e9ff17016264982ce3d7de3fd907dba7 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 4 May 2021 17:08:33 +0100 Subject: fixed problem of repeating Setup() procedure --- cmd/datamaps/main.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'cmd') 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) -- cgit v1.2.3