Struct cor_args::ArgHandler
source · pub struct ArgHandler<'a> { /* private fields */ }Expand description
A handler for managing command-line arguments.
This struct is responsible for handling command-line arguments passed to the application. If a value for a given key is not found in the arguments, it delegates the request to the next handler (if provided).
Examples
use cor_args::{ArgHandler, Handler};
// Create a simple `clap` command
let args = clap::Command::new("myapp")
.arg(clap::Arg::new("example").long("example"))
.get_matches();
// Create a new ArgHandler for a `clap::ArgMatches`
let handler = ArgHandler::new(&args);
// Add a fallback handler
//let handler = handler.next(some_other_handler.into());
// Handle a configuration request matching the `clap::Arg` name
let value = handler.handle_request("example");Implementations§
Trait Implementations§
source§impl<'a> Handler for ArgHandler<'a>
impl<'a> Handler for ArgHandler<'a>
source§fn handle_request(&self, key: &str) -> Option<String>
fn handle_request(&self, key: &str) -> Option<String>
Retrieves a value for the specified key from the command-line arguments.
If the key is not found in the arguments, and if a next handler is provided, it delegates the request
to the next handler. If there’s no next handler or if the key is not found in both the arguments and
the next handler, it returns None.
Arguments
key- The key for which the value needs to be retrieved.
Returns
An Option containing the value associated with the key, or None if the key is not found.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ArgHandler<'a>
impl<'a> !Send for ArgHandler<'a>
impl<'a> !Sync for ArgHandler<'a>
impl<'a> Unpin for ArgHandler<'a>
impl<'a> !UnwindSafe for ArgHandler<'a>
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