pub struct CliContextBuilder { /* private fields */ }Expand description
Builder for CliContext with proper precedence handling
Precedence order (highest to lowest):
- Explicitly set builder values
- Environment variables
- Config file values (if project initialized)
- Defaults
§Example
ⓘ
use mecha10_cli::CliContextBuilder;
use tracing::Level;
let ctx = CliContextBuilder::new()
.config_path(Some("custom/mecha10.json".into()))
.log_level(Level::DEBUG)
.verbose(true)
.dev_mode(true)
.build()?;Implementations§
Source§impl CliContextBuilder
impl CliContextBuilder
Sourcepub fn config_path(self, path: Option<PathBuf>) -> Self
pub fn config_path(self, path: Option<PathBuf>) -> Self
Set config file path
Sourcepub fn working_dir(self, dir: PathBuf) -> Self
pub fn working_dir(self, dir: PathBuf) -> Self
Set working directory
Sourcepub fn postgres_url(self, url: Option<String>) -> Self
pub fn postgres_url(self, url: Option<String>) -> Self
Set PostgreSQL URL
Sourcepub fn build(self) -> Result<CliContext>
pub fn build(self) -> Result<CliContext>
Build the CliContext with proper precedence
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CliContextBuilder
impl RefUnwindSafe for CliContextBuilder
impl Send for CliContextBuilder
impl Sync for CliContextBuilder
impl Unpin for CliContextBuilder
impl UnwindSafe for CliContextBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more