cli

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cli centralises the FastConf command-line flag set so every cmd/* binary registers -dir / -profile / -strict / -watch with identical defaults and semantics, and constructs the Manager via a single canonical path.

Sub-commands embed Flags into their flag.FlagSet, call RegisterFlags, then hand the populated value to LoadConfig[T] together with any command-specific Option overrides. Adding a new CLI binary becomes "wire Flags + call LoadConfig + run business logic" with no boilerplate.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig[T any](ctx context.Context, f Flags, extra ...fastconf.Option) (*fastconf.Manager[T], error)

LoadConfig builds a fastconf.Manager[T] from a populated Flags value plus any extra Option overrides. It is the canonical Manager constructor for CLI binaries; -dir / -profile / -strict / -watch behaviour stays consistent across fastconfd and fastconfctl.

func RegisterFlags

func RegisterFlags(fs *flag.FlagSet, f *Flags)

RegisterFlags registers the shared FastConf flags on the given FlagSet. Defaults are pulled from the fastconf package so any future change to e.g. DefaultDir propagates to every CLI binary automatically.

Types

type Flags

type Flags struct {
	Dir       string
	Profile   string
	Strict    bool
	Watch     bool
	Providers ProviderFlags
}

Flags is the canonical FastConf CLI flag set shared by fastconfd and fastconfctl (and any future binary). Each sub-command embeds one of these inside its own flag.FlagSet via RegisterFlags.

type ProviderFlags

type ProviderFlags []string

ProviderFlags is a repeatable "-provider name=value" flag. Value may be JSON (decoded into a map) or a plain string (wrapped as {"value": s}). Apply converts the collected specs into fastconf.Options on demand.

func (ProviderFlags) Apply

func (p ProviderFlags) Apply(opts *[]fastconf.Option) error

Apply converts the parsed provider specs into fastconf.Options appended onto opts. Each spec is "name=value"; if value is valid JSON it becomes the provider config map, otherwise it is wrapped as {"value": s}. The "env" name is special-cased to a plain Env provider because it predates the registry-based WithProviderByName.

func (*ProviderFlags) Set

func (p *ProviderFlags) Set(v string) error

Set implements flag.Value.

func (*ProviderFlags) String

func (p *ProviderFlags) String() string

String implements flag.Value.

Jump to

Keyboard shortcuts

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