Documentation
¶
Overview ¶
Package config resolves the CLI home directory and loads config.json.
Index ¶
- Constants
- Variables
- func Home(getenv func(string) string) string
- func Path(home string) string
- func SetKeystore(home, backend string, log *slog.Logger) error
- func SetTUIColorScheme(home, scheme string, log *slog.Logger) error
- func SetTUIOrderLevels(home string, levels []int, log *slog.Logger) error
- func ValidBackend(name string) bool
- func ValidColorScheme(name string) bool
- func ValidOrderLevels(levels []int) bool
- type Config
Constants ¶
const ( MinOrderLevel = 1 MaxOrderLevel = 100 MaxOrderLevels = 9 )
Order-size preset bounds. Each level is a percentage of the funding balance (1..100, where 100 = "max"); MaxOrderLevels caps the count at the number of digit keys (1..9) the order UIs can bind. The list is stored as a plain JSON array, so extending it later needs no schema change and an older binary reads a longer list without error.
Variables ¶
var Backends = []string{"file", "keychain"}
Backends are the supported keystore backend names.
var ColorSchemes = []string{"green-red", "red-blue"}
ColorSchemes are the valid persisted tui color-scheme names. They mirror uikit.ColorScheme.String(); config keeps its own copy so it need not import the (charm-dependent) tui/uikit layer. A uikit test pins the two lists together so they cannot drift.
Functions ¶
func SetKeystore ¶
SetKeystore persists the default-keystore-for-new-keys choice into config.json (the `keystore default` command), leaving every other field (baseUrl, and any field this version doesn't model) exactly as it was.
func SetTUIColorScheme ¶
SetTUIColorScheme persists the tui command's up/down color convention ("green-red" or "red-blue") under config.json's "tui" object, leaving every other field — top-level, and any other key inside "tui" — exactly as it was. The tui command calls it off the UI goroutine when the C key toggles the scheme.
func SetTUIOrderLevels ¶
SetTUIOrderLevels persists the tui command's %-of-balance size presets under config.json's "tui" object, leaving every other field alone. The tui command pins the built-in defaults here on first launch.
func ValidBackend ¶
ValidBackend reports whether name is a recognized keystore backend. It is the single home for the "is this a real backend" check — callers (the CLI command, the keystore constructors) should use it rather than re-listing Backends.
func ValidColorScheme ¶
ValidColorScheme reports whether name is a recognized tui color-scheme value.
func ValidOrderLevels ¶
ValidOrderLevels reports whether levels is an acceptable size-preset list: 1..MaxOrderLevels entries, each a percentage in MinOrderLevel..MaxOrderLevel.
Types ¶
type Config ¶
type Config struct {
// Keystore selects where NEWLY CREATED keys' private material goes: "file"
// (default, encrypted file) or "keychain" (the OS keyring). It applies only
// at key creation — every existing key carries its own backend in keys.json,
// and changing this default never moves or re-routes an existing key (that
// is `keystore migrate`'s job).
Keystore string
// BaseURL optionally overrides the REST base URL.
BaseURL string
// WSBaseURL optionally overrides the WebSocket base URL (scheme ws/wss),
// used by the streaming `monitor` command. Empty means it is derived from
// the resolved REST base URL.
WSBaseURL string
// TUIColorScheme is the persisted up/down color convention for the `tui`
// command ("green-red" or "red-blue"), toggled with the C key and saved back
// so it survives across launches. Stored under the "tui" object in
// config.json. Empty means the TUI's default.
TUIColorScheme string
// TUIOrderLevels are the persisted %-of-balance size presets the `tui`
// order UIs bind to number keys (e.g. [10,25,50,100], where 100 renders as
// "max"). Stored under the "tui" object. Nil means unset — the tui command
// pins the built-in defaults on first launch, so a later program update
// never silently changes what a preset key does.
TUIOrderLevels []int
}
Config is the resolved CLI configuration.