1
0
mirror of https://github.com/writeas/writeas-cli synced 2025-07-26 23:08:16 +00:00
writeas-cli/config/directories.go
Rob Loranger a993f00846
ref T594 allow configurable config directory
this adds a configurable directory, currently within the users path for
the configuration, user and post data to be saved.

it is accessible down the stack of the application via the cli.Context,
specificaly c.App.ExtraData which is a function that returns a map of
[string]string under the key 'configDir".
2019-05-29 12:14:07 -07:00

21 lines
395 B
Go

package config
import (
"os"
"path/filepath"
"github.com/writeas/writeas-cli/fileutils"
)
func UserDataDir(dataDirName string) string {
return filepath.Join(parentDataDir(), dataDirName)
}
func DataDirExists(dataDirName string) bool {
return fileutils.Exists(UserDataDir(dataDirName))
}
func CreateDataDir(dataDirName string) error {
return os.Mkdir(UserDataDir(dataDirName), 0700)
}