tui_commander/
command.rs

1pub trait Command<Context> {
2    /// The name of the command, what a user has to type to find the command and execute
3    fn name() -> &'static str
4    where
5        Self: Sized;
6
7    fn build_from_command_name_str(
8        input: &str,
9    ) -> Result<Self, Box<dyn std::error::Error + Send + Sync + 'static>>
10    where
11        Self: Sized;
12
13    fn args_are_valid(args: &[&str]) -> bool
14    where
15        Self: Sized;
16
17    fn execute(
18        &self,
19        arguments: Vec<String>,
20        context: &mut Context,
21    ) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>;
22}
23
24pub struct CommandBox<Context>(pub(crate) Box<dyn Command<Context>>);