Struct falcon_cli::router::CliRouter
source · pub struct CliRouter {
pub commands: HashMap<String, Box<dyn CliCommand>>,
pub shortcuts: HashMap<String, String>,
pub value_flags: HashMap<String, Vec<String>>,
pub categories: HashMap<String, (String, String)>,
}Fields§
§commands: HashMap<String, Box<dyn CliCommand>>§shortcuts: HashMap<String, String>§value_flags: HashMap<String, Vec<String>>§categories: HashMap<String, (String, String)>Implementations§
source§impl CliRouter
impl CliRouter
pub fn new() -> Self
sourcepub fn add<T: CliCommand + Default + 'static>(
&mut self,
alias: &str,
shortcuts: Vec<&str>,
value_flags: Vec<&str>
)
pub fn add<T: CliCommand + Default + 'static>( &mut self, alias: &str, shortcuts: Vec<&str>, value_flags: Vec<&str> )
Link a struct / impl that inherits the CliRouter trait to a command name. Takes three arguments, the full name of the command, a vector of available shortcuts, and a vector of long-form flags (prefixed with dashes (–)) for which a value is expected.
sourcepub fn lookup(&self) -> (&Box<dyn CliCommand>, CliRequest)
pub fn lookup(&self) -> (&Box<dyn CliCommand>, CliRequest)
Taking arguments passed via command line into account, checks all routes that were added and tries to determine the correct impl to execute. This function is automatically executed by the cli_run() function and should never be manually executed.
sourcepub fn add_category(&mut self, alias: &str, name: &str, description: &str)
pub fn add_category(&mut self, alias: &str, name: &str, description: &str)
Add a new top level category that contains CLI commands. Used for organization and to display proper help screens.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CliRouter
impl !Send for CliRouter
impl !Sync for CliRouter
impl Unpin for CliRouter
impl !UnwindSafe for CliRouter
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