getopt

package
v0.1.149 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindConfigFiles

func FindConfigFiles() ([]string, error)

FindConfigFiles returns a list of config.yaml paths in precedence order. Returns: [exeDir/config.yaml, platformDir/config.yaml] This is exported for use by Config.LoadFromYAML().

Types

type Opt

type Opt struct {
	Port                 OptInt    // TCP port the HTTP server binds to
	RunFileDiscovery     OptBool   // Whether to run discovery on startup
	DebugDelayMS         OptInt    // Optional artificial delay for debug/testing
	Profile              OptString // Profiling mode: "", "cpu", "mem", "block", etc.
	EnableCompression    OptBool   // Enable gzip/brotli compression
	EnableHTTPCache      OptBool   // Enable SQLite HTTP response caching
	EnableCachePreload   OptBool   // Enable cache preloading when folders are opened
	SessionSecret        OptString // Secret key for session cookie signing (required)
	SessionSecure        OptBool   // Restrict session cookies to HTTPS
	SessionHttpOnly      OptBool   // Set HttpOnly flag on session cookies
	SessionMaxAge        OptInt    // Max age for session cookies in seconds
	SessionSameSite      OptString // SameSite policy for session cookies (Strict, Lax, None)
	UnlockAccount        OptString // Username to unlock (empty string if not set)
	RestoreLastKnownGood OptBool   // Restore last known good configuration from database on startup
	IncrementETag        OptBool   // Increment application-wide ETag version on startup
}

Package getopt parses runtime configuration from environment variables and command-line flags. Precedence: CLI flags > Environment variables. Opt holds all runtime options parsed from env and CLI flags. All fields use nullable types to track whether they were explicitly set.

func Parse

func Parse() Opt

Parse reads configuration from environment variables and CLI flags. Precedence: CLI flags > Environment variables. YAML config files are NOT handled here - they are handled by Config.LoadFromYAML().

func ParseEnvOnly

func ParseEnvOnly() Opt

ParseEnvOnly reads configuration from environment variables only (no CLI flags). Used by tests to parse env vars set with t.Setenv() without interfering with test flags.

type OptBool

type OptBool struct {
	Bool  bool
	IsSet bool
}

OptBool holds a boolean value and tracks whether it was explicitly set.

type OptInt

type OptInt struct {
	Int   int
	IsSet bool
}

OptInt holds an integer value and tracks whether it was explicitly set.

type OptString

type OptString struct {
	String string
	IsSet  bool
}

OptString holds a string value and tracks whether it was explicitly set.

Jump to

Keyboard shortcuts

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