blob: c621c0840a15cb968ba5fae0b2b7ecacce59269a (
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
|
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;
/// 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),
];
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
}
|