aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
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 {