Added skeleton for program entry.

This commit is contained in:
Thelie 2021-05-07 19:12:19 +02:00
parent cdc5843f5d
commit d5353fb019

View file

@ -168,9 +168,37 @@ fn handle_message(message: Message) -> Option<Message> {
} }
fn main() { fn main() {
let config_path = args().nth(1) let mut server_conf_flag = false;
.expect("no config given"); let mut config_path = None;
let config = get_config(config_path).expect("Could not get config"); 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(); let mut stream = connect::connect_irc(&config).unwrap();