Skip to main content

ConfigParser

Trait ConfigParser 

Source
pub trait ConfigParser:
    Sized
    + Parser
    + ConfigFallback
where Self::Opts: Parser + Default + ConfigSource,
{ // Provided methods fn parse_with_config() -> Self { ... } fn try_parse_with_config() -> Result<Self, Error> { ... } fn parse_with_config_from<I, T>(itr: I) -> Self where I: IntoIterator<Item = T>, T: Into<OsString> + Clone { ... } fn try_parse_with_config_from<I, T>(args: I) -> Result<Self, Error> where I: IntoIterator<Item = T>, T: Into<OsString> + Clone { ... } }
Expand description

Parse a clap struct with optional configuration-file fallback.

Deriving ConfigParser generates an internal optional Opts type and a config-deserialization type, then wires them into this trait.

Provided Methods§

Source

fn parse_with_config() -> Self

Equivalent to Parser::parse, but with config fallback.

Source

fn try_parse_with_config() -> Result<Self, Error>

Equivalent to Parser::try_parse, but with config fallback.

Source

fn parse_with_config_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Equivalent to Parser::parse_from, but with config fallback.

Source

fn try_parse_with_config_from<I, T>(args: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Performs parsing with config fallback and returns clap errors instead of exiting.

Merge precedence is CLI > config. If no config path is available, behavior matches a normal clap parse.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§