config

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config holds the CLI surface for mig: flag parsing, environment fallbacks, and the Config struct passed into the source/metrics/tui layers.

Index

Constants

View Source
const DefaultTheme = "default"

DefaultTheme is the theme name used when the user has not chosen one elsewhere (flag, env, or config file).

Variables

This section is empty.

Functions

func IsListThemes

func IsListThemes(err error) bool

IsListThemes reports whether err is the sentinel returned for --theme=?, so main can exit 0 instead of treating it as a parse error.

Types

type Config

type Config struct {
	// Connection
	Servers  []string
	User     string
	Password string
	Creds    string
	NKey     string
	TLSCert  string
	TLSKey   string
	TLSCA    string
	Context  string
	Name     string

	// Subscription
	Subjects  []string
	Stream    string
	ForceCore bool
	Deliver   DeliverPolicy
	Since     time.Duration
	Unbounded bool

	// UI / behavior
	Refresh      time.Duration
	Stale        time.Duration
	MaxSubjects  int
	MaxPaths     int
	SchemaSample float64
	NoTUI        bool
	JSONPretty   bool
	Theme        string
	ConfigPath   string
	SparkSeconds int // length of the rate sparkline ring, in seconds
	HistSamples  int // per-path numeric reservoir size feeding the histogram

	// Meta
	ShowVersion bool
}

Config is the parsed CLI configuration shared across mig subsystems.

func Default

func Default() Config

Default returns a Config populated with defaults.

func Parse

func Parse(args []string, out io.Writer) (Config, error)

Parse parses argv[1:] into a Config. Returns flag.ErrHelp when --help/-h is asked (caller exits 0). Returns other errors for invalid combinations.

func (Config) Validate

func (c Config) Validate() error

Validate verifies invariants on a parsed Config.

type DeliverPolicy

type DeliverPolicy string

DeliverPolicy maps to JetStream DeliverPolicy. Strings are mapped at the source layer to avoid pulling nats.go into config.

const (
	DeliverNew            DeliverPolicy = "new"
	DeliverAll            DeliverPolicy = "all"
	DeliverByStartTime    DeliverPolicy = "since"
	DeliverLastPerSubject DeliverPolicy = "last-per-subject"
)

DeliverPolicy values, mirroring jetstream.DeliverPolicy options that mig exposes.

Jump to

Keyboard shortcuts

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