config

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Filename into which Config is serialized
	Filename = "config.yaml"

	// DefaultConfigPath is used in the unlikely event that
	// the user has no home directory (no ~), there is no
	// XDG_CONFIG_HOME set
	DefaultConfigPath = ".config/func"

	// DefaultLanguage is intentionaly undefined.
	DefaultLanguage = ""
)

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() string

ConfigPath returns the full path at which to look for a config file.

func Path

func Path() (path string)

Path is derived in the following order, from lowest to highest precedence. 1. The static default is DefaultConfigPath (./.config/func) 2. ~/.config/func if it exists (can be expanded: user has a home dir) 3. The value of $XDG_CONFIG_PATH/func if the environment variable exists. The path is created if it does not already exist.

Types

type Config

type Config struct {
	// Language Runtime
	Language string `yaml:"language"`

	// Confirm Prompts
	Confirm bool `yaml:"confirm"`
}

func Load

func Load(path string) (c Config, err error)

Load the config exactly as it exists at path (no static defaults)

func New

func New() Config

New Config struct with all members set to static defaults. See NewDefaults for one which further takes into account the optional config file.

func NewDefault

func NewDefault() (cfg Config, err error)

Creates a new config populated by global defaults as defined by the config file located in .Path() (the global func settings path, which is

usually ~/.config/func)

func (Config) Save

func (c Config) Save(path string) (err error)

Save the config to the given path

Jump to

Keyboard shortcuts

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