Oauth. Car Backups.
This commit is contained in:
20
cmd/root.go
20
cmd/root.go
@@ -24,9 +24,11 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"git.bullercodeworks.com/brian/expds/data"
|
||||
"git.bullercodeworks.com/brian/expds/helpers"
|
||||
"github.com/adrg/xdg"
|
||||
gap "github.com/muesli/go-app-paths"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@@ -78,9 +80,12 @@ func initConfig() {
|
||||
viper.SetConfigType("yaml")
|
||||
}
|
||||
|
||||
// Default Data dir:
|
||||
appDataDir := filepath.Join(xdg.DataHome, "expds")
|
||||
viper.SetDefault(data.KeyConfigDir, firstDir)
|
||||
viper.SetDefault(data.KeyDebug, false)
|
||||
viper.SetDefault(data.KeyDataDir, helpers.Path(firstDir, "data"))
|
||||
viper.SetDefault(data.KeyDataDir, appDataDir)
|
||||
viper.SetDefault(data.KeyBackupDir, filepath.Join(appDataDir, "backups"))
|
||||
viper.SetDefault(data.KeyVimMode, false)
|
||||
viper.SetConfigFile(cfgFile)
|
||||
viper.AutomaticEnv()
|
||||
@@ -119,7 +124,18 @@ func initConfig() {
|
||||
_, err := os.Stat(dDir)
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println("Creating Data Directory:", dDir)
|
||||
err := os.Mkdir(dDir, 0o755)
|
||||
err := os.MkdirAll(dDir, 0o755)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
bDir := viper.GetString(data.KeyBackupDir)
|
||||
_, err = os.Stat(bDir)
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println("Creating Backups Directory:", bDir)
|
||||
err := os.MkdirAll(bDir, 0o755)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user