config

package
v0.1.114 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config resolves the runtime configuration for the `polycli heimdall` command tree.

Precedence (highest wins): explicit command-line flag > environment variable > config file (~/.polycli/heimdall.toml) > network preset > built-in default. A missing config file is not an error.

Index

Constants

View Source
const (
	ExitOK       = 0
	ExitNodeErr  = 1
	ExitNetErr   = 2
	ExitUsageErr = 3
	ExitSignErr  = 4
)

Exit codes mirror cast conventions (see requirements §2.1).

View Source
const (
	EnvNetwork    = "HEIMDALL_NETWORK"
	EnvRESTURL    = "HEIMDALL_REST_URL"
	EnvRPCURL     = "HEIMDALL_RPC_URL"
	EnvChainID    = "HEIMDALL_CHAIN_ID"
	EnvDenom      = "HEIMDALL_FEE_DENOM"
	EnvTimeout    = "HEIMDALL_TIMEOUT"
	EnvRPCHeaders = "HEIMDALL_RPC_HEADERS"
	EnvNoColor    = "NO_COLOR"
)

Environment-variable names (requirements §2.2).

Variables

This section is empty.

Functions

func PresetNames

func PresetNames() []string

Preset names in stable order (used for error messages + help text).

Types

type Config

type Config struct {
	Network    string
	RESTURL    string
	RPCURL     string
	ChainID    string
	Denom      string
	Timeout    time.Duration
	RPCHeaders map[string]string
	Insecure   bool
	JSON       bool
	Curl       bool
	Color      string // auto|always|never
	Raw        bool
}

Config holds the fully resolved runtime configuration.

func Resolve

func Resolve(f *Flags) (*Config, error)

Resolve assembles the final Config by layering, in order: built-in defaults -> preset -> optional config file -> env vars -> flags. Returns an error if the selected network is unknown or a provided config file is malformed.

type Flags

type Flags struct {
	Mainnet    bool
	Amoy       bool
	Network    string
	RESTURL    string
	RPCURL     string
	ChainID    string
	Denom      string
	TimeoutSec int
	RPCHeaders string
	Insecure   bool
	JSON       bool
	Curl       bool
	Color      string
	NoColor    bool
	Raw        bool
	ConfigPath string
}

Flags holds the raw command-line flag state before resolution. Persistent flags bind to the fields of this struct.

func (*Flags) Register

func (f *Flags) Register(cmd *cobra.Command)

Register binds the persistent heimdall flags to the given command's PersistentFlags set and wires them into f.

type Preset

type Preset struct {
	Name    string
	RESTURL string
	RPCURL  string
	ChainID string
}

Preset is a named set of defaults for a known Heimdall network.

func GetPreset

func GetPreset(name string) (Preset, bool)

GetPreset returns a copy of the named preset, or (Preset{}, false).

Jump to

Keyboard shortcuts

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