confutil

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsConfig

func AbsConfig(path string) string

AbsConfig ensures that path is absolute and if not, prepends the configuration directory. AbsConfig is a no-op if path is an empty string.

func LoadFiles

func LoadFiles(dir, ext string, spec conf.SectionRegistry) ([]*conf.File, error)

LoadFiles loads all files in dir that have the extension ext and parses them using spec.

func MakeOptional

func MakeOptional(reg conf.OptionRegistry) conf.OptionRegistry

MakeOptional makes all options form reg optional by resetting the Required field to false.

func MapToOptions

func MapToOptions(m map[string]interface{}) ([]conf.Option, error)

func SetOption

func SetOption(opts conf.Options, key, val string) conf.Options

SetOption sets a the option key to value by replacing all occurences of the same option in opts.

Types

type MultiOptionRegistry

type MultiOptionRegistry []conf.OptionRegistry

MultiOptionRegistry is a helper type to create a conf.OptionRegistry from multiple registries.

func (MultiOptionRegistry) All

func (mor MultiOptionRegistry) All() []conf.OptionSpec

All merges all option specs form all option registries. Duplicate option specs are removed and the first option spec has priority.

func (MultiOptionRegistry) GetOption

func (mor MultiOptionRegistry) GetOption(opt string) (conf.OptionSpec, bool)

GetOption returns the option spec for opt. The first option spec that matches wins and has priority.

func (MultiOptionRegistry) HasOption

func (mor MultiOptionRegistry) HasOption(opt string) bool

type MultiSectionRegistry

type MultiSectionRegistry []conf.SectionRegistry

MultiSectionRegistry is a helper type to create a conf.SectionRegistry from multiple registries.

func (MultiSectionRegistry) OptionsForSection

func (msr MultiSectionRegistry) OptionsForSection(sec string) (conf.OptionRegistry, bool)

OptionsForSection implements conf.SectionRegistry.

type OptionalOptionRegistry

type OptionalOptionRegistry struct {
	conf.OptionRegistry
}

func (*OptionalOptionRegistry) All

func (optreg *OptionalOptionRegistry) All() []conf.OptionSpec

All wraps OptionRegistry.All and marks al options as "optional".

func (*OptionalOptionRegistry) GetOption

func (optreg *OptionalOptionRegistry) GetOption(opt string) (conf.OptionSpec, bool)

GetOption wraps OptionRegistry.GetOption and marks all options as "optional".

Jump to

Keyboard shortcuts

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