Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns the default config file path. Prefers the XDG-compliant ~/.config/band/config.json, but falls back to the legacy ~/.band/config.json if it exists and the new path doesn't (auto-migration).
Types ¶
type Config ¶
type Config struct {
// Active profile name
ActiveProfile string `json:"active_profile,omitempty"`
// Named profiles (keyed by profile name)
Profiles map[string]*Profile `json:"profiles,omitempty"`
// Global settings
Format string `json:"format,omitempty"`
// Legacy fields — kept for backward compatibility during migration.
// If present and Profiles is empty, auto-migrate to a "default" profile.
ClientID string `json:"client_id,omitempty"`
AccountID string `json:"account_id,omitempty"`
Accounts []string `json:"accounts,omitempty"`
Environment string `json:"environment,omitempty"`
}
Config holds the CLI configuration values persisted to ~/.band/config.json.
func Load ¶
Load reads config from path, overlays env vars, and returns defaults if the file does not exist. The default format is "json".
func (*Config) ActiveProfileConfig ¶
ActiveProfileConfig returns the active profile, resolving legacy config if needed.
func (*Config) HasMultipleEnvironments ¶
HasMultipleEnvironments reports whether the configured profiles span more than one distinct environment. This is used to decide whether to surface the active environment in CLI output — a customer with only prod credentials doesn't need to see "Environment: production" on every command.
func (*Config) ProfileNames ¶
ProfileNames returns sorted profile names.
func (*Config) SetProfile ¶
SetProfile stores a profile and sets it as active.
type Profile ¶
type Profile struct {
ClientID string `json:"client_id,omitempty"`
AccountID string `json:"account_id,omitempty"`
Accounts []string `json:"accounts,omitempty"`
Environment string `json:"environment,omitempty"` // prod, test
}
Profile holds credentials and account info for a single set of API credentials.