Skip to content

config

import "go-cli-template/internal/config"

Index

type Manager

Manager describes configuration persistence behavior.

type Manager interface {
Load() (domain.Config, error)
Save(config domain.Config) error
Exists() (bool, error)
}

type ManagerImpl

ManagerImpl loads and saves configuration files.

type ManagerImpl struct {
// contains filtered or unexported fields
}

func NewManager

func NewManager(cwd string) *ManagerImpl

NewManager returns a config manager rooted at the provided cwd.

func (*ManagerImpl) Exists

func (m *ManagerImpl) Exists() (bool, error)

Exists reports whether a local or global config file exists.

func (*ManagerImpl) Load

func (m *ManagerImpl) Load() (domain.Config, error)

Load reads config with precedence: defaults < global < local.

func (*ManagerImpl) LoadWithOverride

func (m *ManagerImpl) LoadWithOverride(path string) (domain.Config, error)

LoadWithOverride loads config from a specific path, layered on defaults.

func (*ManagerImpl) Save

func (m *ManagerImpl) Save(config domain.Config) error

Save persists config to the global config path.

Source

See internal/config/ for implementation details.