aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2020-07-24 10:12:01 +0100
committerMatthew Lemon <matt@matthewlemon.com>2020-07-24 10:12:01 +0100
commit36f3983b039905c54a957f236e4a9718ea7c918f (patch)
tree46c5424ed0930a7dfbf54ca0f77d05924fc96f01 /cmd
parent3b82b7463987ff637530cb403b6d294978bbd115 (diff)
mostly linting
Diffstat (limited to 'cmd')
-rw-r--r--cmd/datamaps/main.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/datamaps/main.go b/cmd/datamaps/main.go
index 32b7ce8..b0d1c1d 100644
--- a/cmd/datamaps/main.go
+++ b/cmd/datamaps/main.go
@@ -26,34 +26,41 @@ func setUp() (string, error) {
// check if config folder exists
configPath := filepath.Join(dir, configDirName)
dbPath := filepath.Join(configPath, dbName)
+
if _, err := os.Stat(configPath); os.IsNotExist(err) {
log.Println("Config directory does not exist.")
log.Printf("Creating config directory %s\n", configPath)
+
if err := os.Mkdir(filepath.Join(dir, "datamaps-go"), 0700); err != nil {
return "", err
}
} else {
log.Println("Config directory found.")
}
+
if _, err := os.Stat(dbPath); os.IsNotExist(err) {
log.Println("Database does not exist.")
+
_, err = os.Create(dbPath)
+
if err != nil {
return "", err
}
+
log.Printf("Creating database file at %s\n", dbPath)
_, err := datamaps.SetupDB(dbPath)
+
if err != nil {
return "", err
}
} else {
log.Println("Database file found.")
}
+
return dir, nil
}
func main() {
-
opts := datamaps.ParseOptions()
switch opts.Command {