Documentation ¶
Index ¶
- func ConfigInit(path string, recipes string, shopping string) bool
- func DefaultConfigPath() string
- func EnsureDataDirInit() error
- func EnsureUsersInit() error
- func GetHMACKeyBytes() []byte
- func IsLoaded() bool
- func LoadConfig(path string) bool
- func LoadConfigEnv()
- type Config
- type RecipeConfig
- type ShoppingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigInit ¶
Creates a new config file, using the default template, using `path`.
If `recipes` or `shopping` are not empty, the passed string will be passed on to the new config file as locations for each. Otherwise, XDG_DATA_HOME defaults will be used.
If the recipe and shopping dirs don't already exist, they will be created.
`users.toml` will be added to config but not created until needed
func EnsureDataDirInit ¶
func EnsureDataDirInit() error
Tests for the existence of the data directories, if they do not exist then they are created.
Returns nil on success
func EnsureUsersInit ¶
func EnsureUsersInit() error
Tests for the existence of the users file, if it does not exist then an empty one will be created.
Returns nil on success
func GetHMACKeyBytes ¶
func GetHMACKeyBytes() []byte
Returns the HMAC secret key as a byte slice
Panics if config has not been loaded
func LoadConfig ¶
Loads a `go-cook` config file and returns the parsed `Config` struct.
Leave path blank to use default location. NOTE: Defaults only work with Unix based OS atm
func LoadConfigEnv ¶
func LoadConfigEnv()
Loads config from environment vars instead of a config file WARNING: Unimplemented
Types ¶
type Config ¶
type Config struct { Units string `toml:"units"` Recipe RecipeConfig `toml:"recipe"` Shopping ShoppingConfig `toml:"shopping"` Users string `toml:"users"` HMACKey string `toml:"hmac-key"` }
Internal representations for configs, used to (de)serialize to toml
type RecipeConfig ¶
type RecipeConfig struct {
Dir string `toml:"dir"`
}
Internal representations for configs, used to (de)serialize to toml
type ShoppingConfig ¶
type ShoppingConfig struct {
Dir string `toml:"dir"`
}
Internal representations for configs, used to (de)serialize to toml