oa::Cli

Command-line configuration with YAML + argv precedence. Type parameter C is any config struct that implements Default. Defaults are the base layer; a YAML file loaded via -c/--config overrides them; explicit argv flags override those. YAML support YAML loading is the caller’s responsibility. Pass a loader closure to Cli::parse_args_with_yaml to apply YAML fields before argv parsing when a -c/--config path is present.

StRust public API

Declaration

pub struct Cli<C> { /* private fields */ }
Public Rust declaration.

Public Methods

pub fn add_option<T, F>(&mut self, names: &str, field: F, description: &str)where T: ParseCliValue + 'static, F: Fn(&mut C) -> &mut T + Clone + 'static,
pub fn add_flag<F>(&mut self, names: &str, field: F, description: &str)where F: Fn(&mut C, bool) + Clone + 'static,
pub fn add_multi<F>(&mut self, names: &str, field: F, description: &str)where F: Fn(&mut C) -> &mut Vec<String> + Clone + 'static,
pub fn add_positional<T, F>( &mut self, name: &str, field: F, description: &str, required: bool, )where T: ParseCliValue + 'static, F: Fn(&mut C) -> &mut T + Clone + 'static,
pub fn add_subcommand(&mut self, name: &str, description: &str) -> &mut Cmd<C>
pub fn require_subcommand(&mut self, min: i32, max: i32)
pub fn set_epilog(&mut self, text: &str)
pub fn set_fallthrough(&mut self, enable: bool)
pub fn config(&self) -> &C
pub fn config_mut(&mut self) -> &mut C
pub fn into_config(self) -> C
pub fn config_path(&self) -> &str
pub fn verbose(&self) -> i32
pub fn help_requested(&self) -> bool
pub fn got_subcommand(&self, name: &str) -> bool
pub fn active_subcommand(&self) -> &str
pub fn parse_args(&mut self, args: &[String]) -> bool
pub fn parse_args_with_yaml<F>( &mut self, args: &[String], yaml_loader: Option<F>, ) -> boolwhere F: FnOnce(&str, &mut C),
pub fn parse(&mut self) -> bool

Associated Functions

pub fn new(name: &str, description: &str) -> Self

Public Method Documentation

pub fn add_option<T, F>(&mut self, names: &str, field: F, description: &str)where T: ParseCliValue + 'static, F: Fn( &mut C ) -> &mut T + Clone + 'static,
No public source comment is attached to this declaration.
pub fn add_flag<F>(&mut self, names: &str, field: F, description: &str)where F: Fn( &mut C, bool ) + Clone + 'static,
No public source comment is attached to this declaration.
pub fn add_multi<F>(&mut self, names: &str, field: F, description: &str)where F: Fn( &mut C ) -> &mut Vec<String> + Clone + 'static,
No public source comment is attached to this declaration.
pub fn add_positional<T, F>( &mut self, name: &str, field: F, description: &str, required: bool, )where T: ParseCliValue + 'static, F: Fn( &mut C ) -> &mut T + Clone + 'static,
No public source comment is attached to this declaration.
pub fn add_subcommand( &mut self, name: &str, description: &str ) -> &mut Cmd<C>
No public source comment is attached to this declaration.
pub fn require_subcommand( &mut self, min: i32, max: i32 )
No public source comment is attached to this declaration.
pub fn set_epilog( &mut self, text: &str )
No public source comment is attached to this declaration.
pub fn set_fallthrough( &mut self, enable: bool )
No public source comment is attached to this declaration.
pub fn config( &self ) -> &C
No public source comment is attached to this declaration.
pub fn config_mut( &mut self ) -> &mut C
No public source comment is attached to this declaration.
pub fn into_config( self ) -> C
No public source comment is attached to this declaration.
pub fn config_path( &self ) -> &str
No public source comment is attached to this declaration.
pub fn verbose( &self ) -> i32
No public source comment is attached to this declaration.
pub fn help_requested( &self ) -> bool
No public source comment is attached to this declaration.
pub fn got_subcommand( &self, name: &str ) -> bool
No public source comment is attached to this declaration.
pub fn active_subcommand( &self ) -> &str
No public source comment is attached to this declaration.
pub fn parse_args( &mut self, args: &[String] ) -> bool
No public source comment is attached to this declaration.
pub fn parse_args_with_yaml<F>( &mut self, args: &[String], yaml_loader: Option<F>, ) -> boolwhere F: FnOnce( &str, &mut C ),
No public source comment is attached to this declaration.
pub fn parse( &mut self ) -> bool
No public source comment is attached to this declaration.
pub fn new( name: &str, description: &str ) -> Self
No public source comment is attached to this declaration.