1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Core trait for slash commands.
use CommandContext;
use CommandResult;
/// Trait for slash commands.
///
/// Implement this for full control over command behavior, or use
/// [`CustomCommand`](super::CustomCommand) for simple closure-based commands.
///
/// # Example
///
/// ```ignore
/// use agent_core::tui::commands::{SlashCommand, CommandContext, CommandResult};
///
/// struct CounterCommand {
/// count: std::sync::atomic::AtomicUsize,
/// }
///
/// impl SlashCommand for CounterCommand {
/// fn name(&self) -> &str { "count" }
/// fn description(&self) -> &str { "Increment and show counter" }
///
/// fn execute(&self, _args: &str, _ctx: &mut CommandContext) -> CommandResult {
/// let n = self.count.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
/// CommandResult::Message(format!("Count: {}", n + 1))
/// }
/// }
/// ```