[−][src]Struct medusa::Handler
Struct that defines a CLI option handler in a programmatic way.
Methods
impl Handler
[src]
pub fn new() -> Handler
[src]
Create a new empty Handler
instance.
Example
use medusa::Handler; // code ... let mut handler: Handler = Handler::new();
pub fn get_actions(&self) -> Option<&HashMap<String, Variant>>
[src]
Get action handler list in form of HashMap from the current
Handler
instance.
Example
use medusa::{Handler, Variant}; use std::collections::HashMap; let mut handler: Handler = Handler::new(); // code ... if let Some(map) = handler.get_actions() { println!("Got some actions here!"); } else { println!("No actions defined!"); }
pub fn get_hints(&self) -> Option<&HashMap<String, String>>
[src]
Get action hint list in form of HashMap from the current
Handler
instance.
Example
use medusa::{Handler, Variant}; use std::collections::HashMap; let mut handler: Handler = Handler::new(); // code ... if let Some(map) = handler.get_hints() { println!("Got some hints here!"); } else { println!("No hints defined!"); }
pub fn add(&mut self, parameter: String, action: Variant, hint: String)
[src]
Add an action for CLI option handler. Note that you must also provide
function hint for this option handler. This hint will be shown if arguments
passed to this handler are invalid, or when the CLI is calling the --help
option. This kind of hint usually a single line of String
, but it is not
restricted for multi-line String
.
Example
use medusa::{Handler, Variant}; // code ... fn show_help() { println!("This is help message!"); } let mut handler: Handler = Handler::new(); handler.add( String::from("--help"), Variant::Plain(show_help), String::from("Show this help message.") );
Auto Trait Implementations
impl RefUnwindSafe for Handler
impl Send for Handler
impl Sync for Handler
impl Unpin for Handler
impl UnwindSafe for Handler
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,