diff --git a/src/bin/git-add-coauthor.rs b/src/bin/git-add-coauthor.rs index 14d50a7..a31edfb 100644 --- a/src/bin/git-add-coauthor.rs +++ b/src/bin/git-add-coauthor.rs @@ -1,4 +1,4 @@ -use git_mob::{get_available_coauthors, write_coauthors_file, Author}; +use git_mob::{parse_coauthors_file, write_coauthors_file, Author}; use structopt::StructOpt; #[derive(StructOpt, Debug)] @@ -13,11 +13,12 @@ struct Opt { fn main() { let opt = Opt::from_args(); - let mut authors = get_available_coauthors(); + let mut authors = parse_coauthors_file().unwrap_or_default(); let new_author = Author { name: opt.name, email: opt.email, }; + authors.insert(opt.initials, new_author); write_coauthors_file(authors); diff --git a/src/lib.rs b/src/lib.rs index e3882a4..ba05dc4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,7 +65,7 @@ pub fn get_available_coauthors() -> BTreeMap { } } -fn parse_coauthors_file() -> Result, Box> { +pub fn parse_coauthors_file() -> Result, Box> { let coauthors_path = coauthors_file_path(); let coauthors_file = File::open(coauthors_path)?; let reader = BufReader::new(coauthors_file);