Documentation
¶
Overview ¶
Package config loads, resolves and persists CLI configuration. Values are resolved with the precedence flag > environment > config file > default.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
Dir returns the OS-appropriate config directory for the CLI (~/.config/api2convert, %AppData%\api2convert, ~/Library/Application Support/api2convert).
func Save ¶
Save writes config.toml with 0600 permissions (dir 0700), so a stored API key is never group/other-readable. The write is atomic (temp file + rename) so a crash mid-write can't corrupt an existing config, and the 0600 mode is applied explicitly — O_CREATE alone would leave a pre-existing 0644 file world-readable.
Types ¶
type Config ¶
type Config struct {
APIKey string `toml:"api_key,omitempty"`
BaseURL string `toml:"base_url,omitempty"`
Timeout string `toml:"timeout,omitempty"`
PollTimeout string `toml:"poll_timeout,omitempty"`
MaxRetries *int `toml:"max_retries,omitempty"`
Output string `toml:"output,omitempty"`
Concurrency int `toml:"concurrency,omitempty"`
}
Config is the on-disk configuration (config.toml). Durations are stored as human-editable Go duration strings (e.g. "30s", "5m"). MaxRetries is a pointer so an explicit 0 (disable retries) can be distinguished from "unset".
type Flags ¶
type Flags struct {
APIKey string
BaseURL string
Timeout string
PollTimeout string
MaxRetries int
Output string
Concurrency int
}
Flags carries the raw CLI flag values used during resolution. Empty strings, -1 (MaxRetries) and 0 (Concurrency) mean "unset".
type Resolved ¶
type Resolved struct {
APIKey string
BaseURL string
Timeout time.Duration
PollTimeout time.Duration
MaxRetries int // -1 means "use SDK default"
Output string
Concurrency int // 0 means "auto"
}
Resolved is the effective configuration after merging all sources.
type State ¶ added in v1.2.0
type State struct {
// LastUpdateCheck is when the background "newer release?" check last ran. A
// zero value means it has never run.
LastUpdateCheck time.Time `json:"last_update_check,omitempty"`
}
State is machine-managed CLI state, kept separate from the user-edited config.toml so a routine write (e.g. the update-check timestamp) never touches the API-key-bearing config file. It lives beside it as state.json.