config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIBaseURL           = "https://api.public.com"
	DefaultTokenValidityMinutes = 60
)

Variables

View Source
var ErrTradingDisabled = fmt.Errorf("trading is disabled - run 'pub configure' and enable trading to place orders")

ErrTradingDisabled is returned when a trading operation is attempted but trading is disabled.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the configuration directory path. Uses XDG_CONFIG_HOME if set, otherwise ~/.config/pub.

func ConfigPath

func ConfigPath() string

ConfigPath returns the full path to the config file.

func Save

func Save(path string, cfg *Config) error

Save writes configuration to the given path. Creates parent directories if needed.

Types

type Config

type Config struct {
	AccountUUID          string `yaml:"account_uuid"`
	APIBaseURL           string `yaml:"api_base_url"`
	TokenValidityMinutes int    `yaml:"token_validity_minutes"`
	TradingEnabled       bool   `yaml:"trading_enabled"`
}

Config holds the CLI configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with default values.

func Load

func Load(path string) (*Config, error)

Load reads configuration from the given path. Returns default config if file doesn't exist.

func (*Config) CheckTrading

func (c *Config) CheckTrading() error

CheckTrading returns ErrTradingDisabled if trading is not enabled.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that the configuration values are valid. Returns an error describing all validation failures.

Jump to

Keyboard shortcuts

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