conf

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package conf provides shared CLI configuration paths, parsing and durable publication. It does not import command implementations or open storage.

Index

Constants

View Source
const DefaultGatewayURL = "http://127.0.0.1:7420"

Variables

This section is empty.

Functions

func CheckNewOutput

func CheckNewOutput(path string) error

CheckNewOutput rejects an existing output before a later atomic publication. Callers must still use a no-replace publication when creating the result.

func ConfigArgument

func ConfigArgument(args []string) string

ConfigArgument returns an explicit configuration argument for commands that create it.

func ConfigArguments

func ConfigArguments(schema *lfhflag.FlagSet, args []string) []string

ConfigArguments extracts only config options and their values, preserving order and spelling. Register schema's complete options first so a string value resembling -c is not mistaken for a configuration selector.

func DefaultPath

func DefaultPath() (string, error)

DefaultPath resolves the current user's ~/.compactfs/config.toml on each call.

func EnsureFile

func EnsureFile(path string) error

EnsureFile creates a missing private configuration file without truncating an existing one.

func ExpandUser

func ExpandUser(path string) string

ExpandUser expands only ~ and ~/ relative to the current user home.

func FormatBytes

func FormatBytes(value int64) string

FormatBytes renders CLI byte counts with binary units.

func HelpRequested

func HelpRequested(schema *lfhflag.FlagSet, args []string) bool

HelpRequested recognizes help tokens using the actual option types, while respecting values and --. Register all command flags before calling it.

func NormalizeBaseURL

func NormalizeBaseURL(value string, public bool) (string, error)

NormalizeBaseURL validates an HTTP(S) service base URL, preserving its path prefix. Public addresses without a scheme default to HTTPS.

func NormalizeGatewayURL

func NormalizeGatewayURL(value string) (string, error)

NormalizeGatewayURL accepts a gateway host or HTTP(S) base URL. Bare hosts default to the trusted-network HTTP transport.

func OptionPresent

func OptionPresent(flags *lfhflag.FlagSet, args []string, name string) bool

OptionPresent checks CLI tokens using the actual registered option types. It respects -- and consumes nonboolean values even when they look like flags. Call it after registering the command's complete FlagSet.

func OverrideArguments

func OverrideArguments(args []string, overrides ...string) []string

OverrideArguments inserts generated options before the first literal -- delimiter.

func ParseBytes

func ParseBytes(value string) (int64, error)

ParseBytes parses nonnegative binary or decimal capacities, with zero for empty, none or unlimited. It does not apply a storage-specific default.

func SaveGatewayPeers

func SaveGatewayPeers(instancePath string, peers []string) error

SaveGatewayPeers rewrites only this instance's peers while preserving all other TOML settings. It never follows an existing config/lock symlink.

func ServiceInstancePath

func ServiceInstancePath(kind string, port int) (string, error)

ServiceInstancePath returns ~/.compactfs/KIND-PORT.toml; gw maps to gateway.

func WriteNew

func WriteNew(path string, data []byte) error

WriteNew publishes a complete 0600 file without replacing an existing name. Parent directories, file bytes and the final directory entry are durable.

Types

type GatewayOptions

type GatewayOptions struct {
	Gateway    string
	Explicit   bool
	FromCLI    bool
	ConfigPath string
}

GatewayOptions belongs to one CLI invocation. Explicit distinguishes an explicit/configured gateway from the local default, keeping local volumes local.

func PrepareGateway

func PrepareGateway(args []string, schema *lfhflag.FlagSet) (GatewayOptions, []string, error)

prepareGlobalGateway removes -gw from either side of a command name while leaving command flags and positional arguments for their own parser.

func PrepareGatewayAt

func PrepareGatewayAt(args []string, defaultPath string, schema *lfhflag.FlagSet) (GatewayOptions, []string, error)

type ServiceConfig

type ServiceConfig struct {
	Port         int
	GlobalPath   string
	PublicPath   string
	InstancePath string
	// contains filtered or unexported fields
}

ServiceConfig selects the service's public and port-instance configuration. Construction does not read files. Port/PublicPath/InstancePath reflect the final selection after Select or Parse; the caller owns the actual flags and their values.

func NewServiceConfig

func NewServiceConfig(kind string, defaultPort int) (*ServiceConfig, error)

NewServiceConfig records one invocation's paths and defaults without parsing options or loading files. Register all flags before calling Parse.

func ServiceFlagSet

func ServiceFlagSet(kind string, defaultPort int) (*lfhflag.FlagSet, *ServiceConfig, error)

ServiceFlagSet creates an unparsed FlagSet and its deferred service selector.

func (*ServiceConfig) Parse

func (i *ServiceConfig) Parse(flags *lfhflag.FlagSet, args []string) error

Parse selects the instance with native flag/config conversion, then loads global < service public < port instance < explicit -c < CLI. -c= disables all input files. Boolean classification comes from these actual flags.

func (*ServiceConfig) Select

func (i *ServiceConfig) Select(schema *lfhflag.FlagSet, args []string) error

Select resolves this invocation's port and paths without parsing or changing schema's values. Register all flags on schema first. This allows supervisors to select configuration using child options, then parse only their own flags. An instance cannot redirect to another port; help skips file loading.

Jump to

Keyboard shortcuts

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