Documentation
¶
Overview ¶
Package conf provides shared CLI configuration paths, parsing and durable publication. It does not import command implementations or open storage.
Index ¶
- Constants
- func CheckNewOutput(path string) error
- func ConfigArgument(args []string) string
- func ConfigArguments(schema *lfhflag.FlagSet, args []string) []string
- func DefaultPath() (string, error)
- func EnsureFile(path string) error
- func ExpandUser(path string) string
- func FormatBytes(value int64) string
- func HelpRequested(schema *lfhflag.FlagSet, args []string) bool
- func NormalizeBaseURL(value string, public bool) (string, error)
- func NormalizeGatewayURL(value string) (string, error)
- func OptionPresent(flags *lfhflag.FlagSet, args []string, name string) bool
- func OverrideArguments(args []string, overrides ...string) []string
- func ParseBytes(value string) (int64, error)
- func SaveGatewayPeers(instancePath string, peers []string) error
- func ServiceInstancePath(kind string, port int) (string, error)
- func WriteNew(path string, data []byte) error
- type GatewayOptions
- type ServiceConfig
Constants ¶
const DefaultGatewayURL = "http://127.0.0.1:7420"
Variables ¶
This section is empty.
Functions ¶
func CheckNewOutput ¶
CheckNewOutput rejects an existing output before a later atomic publication. Callers must still use a no-replace publication when creating the result.
func ConfigArgument ¶
ConfigArgument returns an explicit configuration argument for commands that create it.
func ConfigArguments ¶
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 ¶
DefaultPath resolves the current user's ~/.compactfs/config.toml on each call.
func EnsureFile ¶
EnsureFile creates a missing private configuration file without truncating an existing one.
func ExpandUser ¶
ExpandUser expands only ~ and ~/ relative to the current user home.
func FormatBytes ¶
FormatBytes renders CLI byte counts with binary units.
func HelpRequested ¶
HelpRequested recognizes help tokens using the actual option types, while respecting values and --. Register all command flags before calling it.
func NormalizeBaseURL ¶
NormalizeBaseURL validates an HTTP(S) service base URL, preserving its path prefix. Public addresses without a scheme default to HTTPS.
func NormalizeGatewayURL ¶
NormalizeGatewayURL accepts a gateway host or HTTP(S) base URL. Bare hosts default to the trusted-network HTTP transport.
func OptionPresent ¶
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 ¶
OverrideArguments inserts generated options before the first literal -- delimiter.
func ParseBytes ¶
ParseBytes parses nonnegative binary or decimal capacities, with zero for empty, none or unlimited. It does not apply a storage-specific default.
func SaveGatewayPeers ¶
SaveGatewayPeers rewrites only this instance's peers while preserving all other TOML settings. It never follows an existing config/lock symlink.
func ServiceInstancePath ¶
ServiceInstancePath returns ~/.compactfs/KIND-PORT.toml; gw maps to gateway.
Types ¶
type GatewayOptions ¶
GatewayOptions belongs to one CLI invocation. Explicit distinguishes an explicit/configured gateway from the local default, keeping local volumes local.
func PrepareGateway ¶
prepareGlobalGateway removes -gw from either side of a command name while leaving command flags and positional arguments for their own parser.
func PrepareGatewayAt ¶
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 ¶
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.