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