blob: 8061344b965b5aff77c253f7c65a1e5c631bf76c (
plain)
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
|
use Command;
use std::collections::HashMap;
mod account;
pub use self::account::Account;
mod status;
pub use self::status::Status;
mod connect;
pub use self::connect::Connect;
mod disconnect;
pub use self::disconnect::Disconnect;
mod custom_relay;
pub use self::custom_relay::CustomRelay;
/// Returns a map of all available subcommands with their name as key.
pub fn get_commands() -> HashMap<&'static str, Box<Command>> {
let commands: Vec<Box<Command>> = vec![
Box::new(Account),
Box::new(Status),
Box::new(Connect),
Box::new(Disconnect),
Box::new(CustomRelay),
];
let mut map = HashMap::new();
for cmd in commands {
if let Some(_) = map.insert(cmd.name(), cmd) {
panic!("Multiple commands with the same name");
}
}
map
}
|