uconfig

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: BSD-3-Clause, MIT Imports: 13 Imported by: 0

README

uConfig

This is a slightly altered version of the https://github.com/omeid/uconfig/.

All credits for this module should go to the original creator.

Changes made in this package:

  • Removed go.mod and go.sum files;
  • Renamed packages;
  • Removed examples directory;
  • Changed github.com/google/go-cmp/cmp to github.com/stretchr/testify to reduce dependencies;
  • Added a formatted usage output to print the configuration in more useful formats for easy copy and pasting;

Documentation

Overview

Package uconfig provides advanced command line flags supporting defaults, env vars, and config structs.

Index

Constants

This section is empty.

Variables

View Source
var ErrUsage = plugins.ErrUsage
View Source
var UsageOutput io.Writer = os.Stdout

UsageOutput is the io.Writer used by Usage message printer.

Functions

func Must

func Must(conf interface{}, plugins ...plugins.Plugin)

Must is like New but also calls Parse and panics instead of returning errors. This is useful in tests.

Types

type Config

type Config interface {
	// Parse will call the parse method of all the added pluginss in the order
	// that the pluginss were registered, it will return early as soon as any
	// plugins fails.
	// You must call this before using the config value.
	Parse() error

	// Usage provides a simple usage message based on the meta data registered
	// by the pluginss.
	Usage()

	// FormattedUsage provides the config used in a desired format: env, yaml or json
	FormattedUsage(format string)
}

Config is the config manager.

func Classic

func Classic(conf interface{}, files Files, userPlugins ...plugins.Plugin) (Config, error)

Classic creates a uconfig manager with defaults,environment variables, and flags (in that order) and optionally file loaders based on the provided Files map and parses them right away.

func New

func New(conf interface{}, ps ...plugins.Plugin) (Config, error)

New returns a new Config. The conf must be a pointer to a struct.

type Files

type Files = file.Files

Files represents a set of file paths and the appropriate unmarshaller function.

Directories

Path Synopsis
Package flat provides a flat view of an arbitrary nested structs.
Package flat provides a flat view of an arbitrary nested structs.
internal
f
Package f provides simple test fixtures for uconfig.
Package f provides simple test fixtures for uconfig.
Package plugins describes the uconfig provider interface.
Package plugins describes the uconfig provider interface.
defaults
Package defaults provides flags support for uconfig
Package defaults provides flags support for uconfig
env
Package env provides environment variables support for uconfig
Package env provides environment variables support for uconfig
file
Package file provides config file support for uconfig
Package file provides config file support for uconfig
flag
Package flag provides flags support for uconfig
Package flag provides flags support for uconfig
secret
Package secret enable uconfig to integrate with secret plugins.
Package secret enable uconfig to integrate with secret plugins.

Jump to

Keyboard shortcuts

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