config

package
v0.0.0-...-a60c800 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyRecipeDir   string = "RECIPE_DIR"
	KeyShoppingDir        = "SHOPPING_DIR"
	KeyUnits              = "UNITS"
)

Constant key for reliably accessing `config.Get`

Variables

This section is empty.

Functions

func ConfigInit

func ConfigInit(path string, recipes string, shopping string) bool

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.

func DefaultConfigPath

func DefaultConfigPath() string

Returns the default config filepath

func DefaultRecipesPath

func DefaultRecipesPath() string

Returns the default recipes directory path

func DefaultShoppingPath

func DefaultShoppingPath() string

Returns the default shopping directory path

func Get

func Get(key string) string

Returns config variable based on key.

Will panic if unloaded configs are accessed.

func IsLoaded

func IsLoaded() bool

func LoadConfig

func LoadConfig(path string) bool

Loads a `cooklang-go` 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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL