mail4agent_messenger_shell/cli/
mod.rs1#[cfg(feature = "wake-claude")]
19pub mod claude_channel;
20pub mod enroll;
21pub mod ensure_agent_webhooks;
22#[cfg(feature = "wake-grok")]
23pub mod grok_listen;
24pub mod inbox;
25pub mod mail;
26#[cfg(feature = "wake-grok")]
27pub mod node_client;
28pub mod send;
29pub mod web_client;
30
31pub const COMMANDS: &[&str] = &["web-client", "node-client", "grok-listen", "claude-channel", "inbox", "send", "mail", "ensure-agent-webhooks", "enroll"];
33
34pub fn dispatch(command: &str, args: Vec<String>) -> Result<(), String> {
36 match command {
37 "web-client" => web_client::run(args),
38 #[cfg(feature = "wake-grok")]
39 "node-client" => node_client::run(args),
40 #[cfg(feature = "wake-grok")]
41 "grok-listen" => grok_listen::run(args),
42 #[cfg(not(feature = "wake-grok"))]
43 "node-client" | "grok-listen" => return Err("this build was made without feature wake-grok".to_string()),
44 #[cfg(feature = "wake-claude")]
45 "claude-channel" => claude_channel::run(args),
46 "inbox" => inbox::run(args),
47 "send" => send::run(args),
48 "mail" => mail::run(args),
49 "ensure-agent-webhooks" => ensure_agent_webhooks::run(args),
50 "enroll" => enroll::run(args),
51 other => return Err(format!("unknown command {other:?}; commands: {}", COMMANDS.join(", "))),
52 }
53 Ok(())
54}
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn an_unknown_command_is_named_not_run() {
62 let e = dispatch("nope", vec![]).unwrap_err();
63 assert!(e.contains("nope") && e.contains("web-client") && e.contains("mail"));
64 }
65
66 #[test]
67 fn enroll_is_a_command() {
68 assert!(COMMANDS.contains(&"enroll"));
69 }
70}