diff --git a/src/main.rs b/src/main.rs index 6b7f18e..988c2df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -168,9 +168,37 @@ fn handle_message(message: Message) -> Option { } fn main() { - let config_path = args().nth(1) - .expect("no config given"); - let config = get_config(config_path).expect("Could not get config"); + let mut server_conf_flag = false; + let mut config_path = None; + let mut server_conf_path = None; + for arg in args().skip(1) { + match arg.as_str() { + "-s" => server_conf_flag = true, + "-h" => { + println!("Usage: mention2mail [config file] [-s server config directory]"); + }, + _ => if server_conf_flag { + server_conf_path = Some(arg); + } else { + config_path = Some(arg); + } + } + } + + let mut config; + + match config_path { + Some(p) => config = get_config(p) + .expect("Could not get config"), + None => config = get_config("/etc/Mention2Mail/config.toml") + .expect("Could not get default config in /etc/Mention2Mail/default.toml"), + } + + match server_conf_path { + Some(p) => config = get_server_config(config, p) + .expect("Could not get server config."), + None => (), + } let mut stream = connect::connect_irc(&config).unwrap();