diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2021-05-04 17:08:33 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2021-05-04 17:08:33 +0100 |
commit | 47415cc7e9ff17016264982ce3d7de3fd907dba7 (patch) | |
tree | 55bf003294f1669a74dfaa995371582e76a6c1b7 | |
parent | 4457cd61f10565c5fa1abafc5e763fb676c4293f (diff) |
fixed problem of repeating Setup() procedure
-rw-r--r-- | cmd/datamaps/main.go | 17 | ||||
-rw-r--r-- | datamaps/config.go | 7 | ||||
-rwxr-xr-x | datamaps/main | bin | 13848736 -> 0 bytes |
3 files changed, 19 insertions, 5 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) diff --git a/datamaps/config.go b/datamaps/config.go index ec6f91e..590e07d 100644 --- a/datamaps/config.go +++ b/datamaps/config.go @@ -15,6 +15,10 @@ const ( const Usage = ` usage: datamaps COMMAND [OPTIONS] +datamaps will NOT create configuration files automatically. Ensure this is handled by +calling: "datamaps setup". This will create the database file required to run the +application. + -Managing datamap files- Command: datamap @@ -62,6 +66,7 @@ func NewDBPathChecker(h getUserConfigDir) *DBPathChecker { // Check returns true if the necessary config files (including // the database) are in place - false if not func (db *DBPathChecker) Check() bool { + println("In Check() method") userConfig, err := db.userConfig() if err != nil { log.Fatal(err) @@ -216,7 +221,7 @@ func nextString(args []string, i *int, message string) string { func processOptions(opts *Options, allArgs []string) { if len(allArgs) == 0 { - allArgs = append(allArgs, "help") + allArgs = append(allArgs, "checkdb") } switch allArgs[0] { case "import": diff --git a/datamaps/main b/datamaps/main Binary files differdeleted file mode 100755 index a781830..0000000 --- a/datamaps/main +++ /dev/null |