blob: 2a0a471373873e469745bf6bc7cb3ff60aa05778 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
use std::io::{self, BufRead};
#[cfg(test)]
mod tests;
fn handle_alias(s: &str) {
let alias = build_alias(s);
}
fn build_alias(s: &str) -> String {
// Replace , ' " with nothing
let mut split: Vec<&str> = s.split_whitespace().collect();
// Remove "From: "
split.remove(0);
let mut alias_line = String::from("alias ");
if split.len() == 1 {
alias_line.push_str(&format!("{} ", split[0].to_lowercase()));
alias_line.push_str(&split.join(" "))
} else if split.len() == 2 {
alias_line.push_str(&format!("{} ", split[0].to_lowercase()));
alias_line.push_str(&split.join(" "));
} else if split.len() > 2 {
alias_line.push_str(&format!("{}-{} ", split[split.len() - 2], split[0]).to_lowercase());
alias_line.push_str(&split.join(" "));
}
alias_line
}
fn main() {
let stdin = io::stdin();
let input: Vec<String> = stdin.lock().lines().map(|line| line.unwrap()).collect();
for line in &input {
if line.starts_with("From: ") {
println!("!!!!!!!! {}", line);
// run matcher function
handle_alias(line);
}
}
for l in &input {
println!("{}", l);
}
// if alias not new
// do nothing
// if alias is new
// if real_alias is in alias file
// if email address is in alias file
// do nothing
//
// find all instances of real_alias
// get instance with greatest id number
//
// change real_alias to "#{real_alias}-#{id + 1}"
//
// if only one instance
// append "-2" to real_alias
//
// add alias to alias file
}
|