use crate::error::ModCliError;
use crate::loader::CommandRegistry;
pub trait Command {
fn name(&self) -> &str;
fn aliases(&self) -> &[&str] {
&[]
}
fn help(&self) -> Option<&str> {
None
}
fn hidden(&self) -> bool {
false
}
fn required_caps(&self) -> &[&str] {
&[]
}
fn validate(&self, _args: &[String]) -> Result<(), ModCliError> {
Ok(())
}
fn execute(&self, args: &[String]);
fn execute_with(&self, args: &[String], _registry: &CommandRegistry) {
self.execute(args)
}
}
#[cfg(feature = "async")]
pub trait AsyncCommand: Send + Sync {
fn name(&self) -> &str;
fn aliases(&self) -> &[&str] {
&[]
}
fn execute_async<'a>(
&'a self,
args: &'a [String],
) -> core::pin::Pin<Box<dyn core::future::Future<Output = Result<(), ModCliError>> + Send + 'a>>;
}