pub struct Config {
pub provider: Provider,
pub model: String,
pub api_key: String,
pub message_level: MessageLevel,
pub max_completion_tokens: u32,
pub base_url: Option<String>,
}Fields§
§provider: Provider§model: String§api_key: StringAPI key. Prefer the provider env var (OPENAI_API_KEY /
ANTHROPIC_API_KEY) and leave this empty in the file.
message_level: MessageLevel§max_completion_tokens: u32Token budget for the generated message. Sent to OpenAI as
max_completion_tokens and to Anthropic as max_tokens
(each provider’s current parameter name).
base_url: Option<String>Optional API base URL override (no trailing slash needed). Useful for OpenAI-compatible endpoints.
Implementations§
Source§impl Config
impl Config
Sourcepub fn config_path() -> PathBuf
pub fn config_path() -> PathBuf
Canonical config file path (used for creation and display).
Resolution: $SI_GIT_COMMIT_CONFIG, otherwise
<config_dir>/si-git-commit/config.toml (e.g.
~/.config/si-git-commit/config.toml on Linux,
~/Library/Application Support/si-git-commit/config.toml on macOS).
Sourcepub fn candidate_paths() -> Vec<PathBuf>
pub fn candidate_paths() -> Vec<PathBuf>
Candidate paths searched when loading, in priority order.
Includes the legacy-style ~/.si-git-commit.toml so a hand-created
file in the home directory is still discovered.
pub fn find_existing_path() -> Option<PathBuf>
Sourcepub fn settings_reference() -> String
pub fn settings_reference() -> String
Human-readable reference to the settings file, for help and errors.
pub fn load() -> Result<Self>
Sourcepub fn load_or_default() -> Self
pub fn load_or_default() -> Self
Load if a config file exists, otherwise return defaults.
Used by ghsi config display commands so they work before init.
pub fn load_from(path: &PathBuf) -> Result<Self>
Sourcepub fn apply_env_overrides(&mut self)
pub fn apply_env_overrides(&mut self)
Environment overrides: SI_GIT_COMMIT_MODEL,
SI_GIT_COMMIT_PROVIDER, and the provider API-key env vars.
Sourcepub fn env_api_key(&self) -> Option<(String, String)>
pub fn env_api_key(&self) -> Option<(String, String)>
API key found in the environment, as (variable name, value).
Checks SI_GIT_COMMIT_API_KEY first, then the provider variable
(OPENAI_API_KEY / ANTHROPIC_API_KEY). This is how a system-wide
key exported from your shell profile is picked up automatically.
Sourcepub fn stored_api_key() -> Option<String>
pub fn stored_api_key() -> Option<String>
API key stored in the settings file itself, ignoring the
environment. None when there is no file or no key in it.
Sourcepub fn require_api_key(&self) -> Result<String>
pub fn require_api_key(&self) -> Result<String>
Resolve the effective API key or return an error that points at both the settings file and the env var.
pub fn effective_base_url(&self) -> String
pub fn save(&self) -> Result<PathBuf>
pub fn save_to(&self, path: &PathBuf) -> Result<()>
Sourcepub fn init_if_missing() -> Result<(PathBuf, bool)>
pub fn init_if_missing() -> Result<(PathBuf, bool)>
Create the config file with defaults if it does not exist.
Returns (path, created).