aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-04-21 16:49:18 -0400
committerTeddy Wing2016-04-21 16:49:18 -0400
commit3a5b7dd83642f5ab93aa70b612dcdbbc10e70935 (patch)
tree3acccfa2ad6b5b0f088e98baa9c5dce77285e922
parent222ade989e6d723435e60ff8e5d60a64b3003af3 (diff)
downloadmutt-alias-auto-add-3a5b7dd83642f5ab93aa70b612dcdbbc10e70935.tar.bz2
find_alias_in_file: Return list of aliases not alias lines
My next step is to get the list produced by this function and use it to build a new alias of `#{alias}-#{id + 1}`. In trying to figure out how best to do that, I realised that it would be easier to do if I had actual aliases to work with instead of full Mutt alias lines that I'd have to parse (again). Update our function to give us a list of aliases instead of full alias lines.
-rw-r--r--src/main.rs2
-rw-r--r--src/tests.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 06f6eb9..fdeab31 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -102,7 +102,7 @@ fn find_alias_in_file(alias: &Alias, file: &str) -> Result<Vec<String>, AliasSea
}
if split[1].starts_with(&alias.alias) {
- matches.push(line.to_owned());
+ matches.push(split[1].to_owned());
}
}
diff --git a/src/tests.rs b/src/tests.rs
index df61825..0dc3901 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -75,8 +75,8 @@ fn find_alias_in_file_alias_is_new() {
fn find_alias_in_file_finds_a_match() {
assert_eq!(
Ok(vec![
- "alias farnsworth-hubert Hubert Farnsworth <professor@planetexpress.com>".to_owned(),
- "alias farnsworth-hubert-2 Hubert Farnsworth <davincifan@planetexpress.com>".to_owned()
+ "farnsworth-hubert".to_owned(),
+ "farnsworth-hubert-2".to_owned()
]),
find_alias_in_file(
&Alias {