mirror of
https://github.com/writeas/writeas-cli
synced 2025-07-26 23:08:16 +00:00

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".
21 lines
395 B
Go
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)
|
|
}
|