zeph_commands/handlers/
experiment.rs1use std::future::Future;
7use std::pin::Pin;
8
9use crate::context::CommandContext;
10use crate::{CommandError, CommandHandler, CommandOutput, SlashCategory};
11
12pub struct ExperimentCommand;
18
19impl CommandHandler<CommandContext<'_>> for ExperimentCommand {
20 fn name(&self) -> &'static str {
21 "/experiment"
22 }
23
24 fn description(&self) -> &'static str {
25 "Experimental features"
26 }
27
28 fn args_hint(&self) -> &'static str {
29 "[subcommand]"
30 }
31
32 fn category(&self) -> SlashCategory {
33 SlashCategory::Advanced
34 }
35
36 fn feature_gate(&self) -> Option<&'static str> {
37 Some("experiments")
38 }
39
40 fn handle<'a>(
41 &'a self,
42 ctx: &'a mut CommandContext<'_>,
43 args: &'a str,
44 ) -> Pin<Box<dyn Future<Output = Result<CommandOutput, CommandError>> + Send + 'a>> {
45 Box::pin(async move {
46 let input = if args.is_empty() {
47 "/experiment".to_owned()
48 } else {
49 format!("/experiment {args}")
50 };
51 let result = ctx.agent.handle_experiment(&input).await?;
52 if result.is_empty() {
53 Ok(CommandOutput::Silent)
54 } else {
55 Ok(CommandOutput::Message(result))
56 }
57 })
58 }
59}