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