pub struct ConfigBuilder { /* private fields */ }Expand description
Builder for functional-style configuration.
Provides a chainable API for defining configuration options, similar to
the JavaScript makeConfig API.
§Example
ⓘ
use lino_arguments::make_config;
let config = make_config(|c| {
c.lenv(".lenv")
.option("port", "Server port", "3000")
.option_short("api-key", 'k', "API key", "")
.flag("verbose", "Enable verbose logging")
});Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn about(&mut self, about: &str) -> &mut Self
pub fn about(&mut self, about: &str) -> &mut Self
Set the application description for help text.
Sourcepub fn version(&mut self, version: &str) -> &mut Self
pub fn version(&mut self, version: &str) -> &mut Self
Set the application version for –version flag.
Sourcepub fn lenv(&mut self, path: &str) -> &mut Self
pub fn lenv(&mut self, path: &str) -> &mut Self
Load a .lenv configuration file (without overriding existing env vars).
Sourcepub fn lenv_override(&mut self, path: &str) -> &mut Self
pub fn lenv_override(&mut self, path: &str) -> &mut Self
Load a .lenv configuration file, overriding existing env vars.
Sourcepub fn env(&mut self, path: &str) -> &mut Self
pub fn env(&mut self, path: &str) -> &mut Self
Load a .env configuration file (without overriding existing env vars).
Sourcepub fn env_override(&mut self, path: &str) -> &mut Self
pub fn env_override(&mut self, path: &str) -> &mut Self
Load a .env configuration file, overriding existing env vars.
Sourcepub fn option(
&mut self,
name: &str,
description: &str,
default: &str,
) -> &mut Self
pub fn option( &mut self, name: &str, description: &str, default: &str, ) -> &mut Self
Define a string/number option with a long name, description, and default value.
Sourcepub fn option_short(
&mut self,
name: &str,
short: char,
description: &str,
default: &str,
) -> &mut Self
pub fn option_short( &mut self, name: &str, short: char, description: &str, default: &str, ) -> &mut Self
Define a string/number option with both short and long names.
Sourcepub fn flag(&mut self, name: &str, description: &str) -> &mut Self
pub fn flag(&mut self, name: &str, description: &str) -> &mut Self
Define a boolean flag (defaults to false).
Sourcepub fn flag_short(
&mut self,
name: &str,
short: char,
description: &str,
) -> &mut Self
pub fn flag_short( &mut self, name: &str, short: char, description: &str, ) -> &mut Self
Define a boolean flag with a short name.
Auto Trait Implementations§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnsafeUnpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
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