From 5a30da3fbdab17ecbcacb09b38d4cd9faf9e3044 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 24 Jul 2020 15:28:02 +0100 Subject: starting to add new code --- cmd/datamaps/main.go | 4 ++++ go.mod | 3 +-- pkg/datamaps/config.go | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/datamaps/main.go b/cmd/datamaps/main.go index 74a8133..cc634a6 100644 --- a/cmd/datamaps/main.go +++ b/cmd/datamaps/main.go @@ -12,6 +12,10 @@ import ( ) func main() { + env := datamaps.DetectConfig() + if !env { + datamaps.SetUp() + } opts := datamaps.ParseOptions() switch opts.Command { diff --git a/go.mod b/go.mod index 79eedf2..f2f8c21 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,8 @@ module github.com/yulqen/datamaps-go go 1.14 require ( - github.com/cweill/gotests v1.5.3 // indirect github.com/mattn/go-sqlite3 v1.14.0 github.com/tealeg/xlsx v1.0.5 - github.com/urfave/cli/v2 v2.2.0 github.com/yulqen/coords v0.1.0 + golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305 // indirect ) diff --git a/pkg/datamaps/config.go b/pkg/datamaps/config.go index 713ad5a..687166c 100644 --- a/pkg/datamaps/config.go +++ b/pkg/datamaps/config.go @@ -11,6 +11,15 @@ const ( dbName = "datamaps.db" ) +// DetectConfig looks for the configuration directory and +// files, and the database file needed to run the application. +func DetectConfig() bool { + dir, err := os.UserConfigDir() + if err != nil { + return "", err + } +} + // SetUp creates the config directory and requisite files func SetUp() (string, error) { dir, err := os.UserConfigDir() -- cgit v1.2.3