pub struct ConfigPaths {
pub global: PathBuf,
pub project: Option<PathBuf>,
pub custom: Option<PathBuf>,
pub auth: PathBuf,
pub cache_dir: PathBuf,
}Expand description
Resolved paths for all config layers.
Fields§
§global: PathBufGlobal config file path.
project: Option<PathBuf>Project config file path (nearest opencode.json up to git root).
custom: Option<PathBuf>Custom config path from OPENCODE_CONFIG env var.
auth: PathBufAuth file path.
cache_dir: PathBufCache directory for this tool.
Implementations§
Source§impl ConfigPaths
impl ConfigPaths
Sourcepub fn discover() -> Result<Self>
pub fn discover() -> Result<Self>
Discover all config paths following OpenCode conventions.
This respects environment variables:
OPENCODE_CONFIG: custom config file pathOPENCODE_CONFIG_DIR: custom config directoryOPENCODE_CONFIG_CONTENT: inline config (not file-based, skipped)XDG_CONFIG_HOME: XDG config directory override
Sourcepub fn global_config_path() -> Result<PathBuf>
pub fn global_config_path() -> Result<PathBuf>
Get the global config path.
Checks in order:
OPENCODE_CONFIG_DIRenv var~/.config/opencode/opencode.json$XDG_CONFIG_HOME/opencode/opencode.json$HOME/.opencode.json(fallback)
Sourcepub fn project_config_path() -> Result<Option<PathBuf>>
pub fn project_config_path() -> Result<Option<PathBuf>>
Find the project-level config by traversing up to the git root.
Starts from the current directory and walks up the tree
until finding opencode.json or hitting the git root.
Sourcepub fn managed_config_path() -> Option<PathBuf>
pub fn managed_config_path() -> Option<PathBuf>
Get the managed config path for the current platform (read-only awareness).
Sourcepub fn path_for_layer(&self, layer: ConfigLayer) -> Option<&PathBuf>
pub fn path_for_layer(&self, layer: ConfigLayer) -> Option<&PathBuf>
Get the path for a specific config layer.
Trait Implementations§
Source§impl Clone for ConfigPaths
impl Clone for ConfigPaths
Source§fn clone(&self) -> ConfigPaths
fn clone(&self) -> ConfigPaths
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConfigPaths
impl RefUnwindSafe for ConfigPaths
impl Send for ConfigPaths
impl Sync for ConfigPaths
impl Unpin for ConfigPaths
impl UnsafeUnpin for ConfigPaths
impl UnwindSafe for ConfigPaths
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more