use slash_lang::parser::ast::Arg;
use crate::executor::{CommandOutput, ExecutionError, PipeValue};
#[derive(Debug, Clone, PartialEq)]
pub struct MethodDef {
pub name: &'static str,
pub takes_value: bool,
}
impl MethodDef {
pub const fn flag(name: &'static str) -> Self {
Self {
name,
takes_value: false,
}
}
pub const fn with_value(name: &'static str) -> Self {
Self {
name,
takes_value: true,
}
}
}
pub trait SlashCommand: Send + Sync {
fn name(&self) -> &str;
fn methods(&self) -> &[MethodDef];
fn execute(
&self,
primary: Option<&str>,
args: &[Arg],
input: Option<&PipeValue>,
) -> Result<CommandOutput, ExecutionError>;
}