aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/datamaps/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/datamaps/config.go')
-rw-r--r--pkg/datamaps/config.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/pkg/datamaps/config.go b/pkg/datamaps/config.go
index 94ce068..dbea8b7 100644
--- a/pkg/datamaps/config.go
+++ b/pkg/datamaps/config.go
@@ -16,7 +16,9 @@ func getUserConfigDir() (string, error) {
if err != nil {
return "", err
}
+
configPath := filepath.Join(dir, configDirName)
+
return configPath, nil
}
@@ -25,10 +27,11 @@ func defaultDMPath() (string, error) {
if err != nil {
return "", err
}
+
return filepath.Join(dir, "Documents", "datamaps"), nil
}
-// Options for the whole CLI application
+// Options for the whole CLI application.
type Options struct {
Command string
DBPath string
@@ -43,13 +46,16 @@ func defaultOptions() *Options {
if err != nil {
log.Fatalf("Unable to get user config directory %v", err)
}
+
dmpath, err := defaultDMPath()
+
if err != nil {
log.Fatalf("Unable to get default datamaps directory %v", err)
}
+
return &Options{
Command: "help",
- DBPath: filepath.Join(dbpath, "datamaps.db"),
+ DBPath: filepath.Join(dbpath, dbName),
DMPath: dmpath,
DMName: "Unnamed Datamap",
DMOverwrite: false,
@@ -57,13 +63,14 @@ func defaultOptions() *Options {
}
}
-// nextString get the next string in a slice
+// nextString get the next string in a slice.
func nextString(args []string, i *int, message string) string {
if len(args) > *i+1 {
*i++
} else {
log.Fatal(message)
}
+
return args[*i]
}
@@ -78,7 +85,9 @@ func processOptions(opts *Options, allArgs []string) {
default:
log.Fatal("No relevant command provided.")
}
+
restArgs := allArgs[1:]
+
for i := 0; i < len(allArgs[1:]); i++ {
arg := restArgs[i]
switch arg {
@@ -98,5 +107,6 @@ func processOptions(opts *Options, allArgs []string) {
func ParseOptions() *Options {
opts := defaultOptions()
processOptions(opts, os.Args[1:])
+
return opts
}