Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
eupn committed Sep 18, 2019
1 parent 3956322 commit d2e46cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
15 changes: 11 additions & 4 deletions src/copirate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt::{Display, Formatter, Result as FmtResult};
use std::fs;
use std::path::Path;

use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

use crate::BoxResult;

Expand Down Expand Up @@ -33,7 +33,9 @@ impl CoPirates {
/// Otherwise, opens the existing one.
pub fn create_or_open(copirates_path: &Path) -> BoxResult<CoPirates> {
if !copirates_path.exists() {
let empty_copirates = CoPirates { copirates: HashMap::new() };
let empty_copirates = CoPirates {
copirates: HashMap::new(),
};
empty_copirates.save(copirates_path)?;
}

Expand Down Expand Up @@ -65,7 +67,9 @@ impl CoPirates {

/// Removes existing copirate
pub fn remove(&mut self, initials: &str) -> BoxResult<()> {
self.copirates.remove(initials).ok_or(format!("Co-pirate with alias '{}' is not found!", initials))?;
self.copirates
.remove(initials)
.ok_or(format!("Co-pirate with alias '{}' is not found!", initials))?;
Ok(())
}

Expand All @@ -84,7 +88,10 @@ pub(crate) fn add(copirates_file: &str, initials: &str, name: &str, email: &str)
let copirates_path = &ship.join(copirates_file);
let mut existing_copirates = CoPirates::create_or_open(copirates_path)?;

let copirate = CoPirate { name: name.to_owned(), email: email.to_owned() };
let copirate = CoPirate {
name: name.to_owned(),
email: email.to_owned(),
};
existing_copirates.add(initials, copirate)?;
existing_copirates.save(copirates_path)?;

Expand Down
16 changes: 10 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ enum CopirateSubcommand {
},
/// Removes co-pirate from the list
#[structopt(name = "remove")]
Remove {
initials: String,
},
Remove { initials: String },
}

#[derive(StructOpt, Clone, Debug)]
Expand All @@ -64,7 +62,7 @@ enum Command {
#[structopt(name = "copirate")]
Copirate {
#[structopt(subcommand)]
cmd: CopirateSubcommand
cmd: CopirateSubcommand,
},
/// Called from the git hook only
#[structopt(name = "prepare-commit-msg")]
Expand All @@ -89,8 +87,14 @@ pub fn run() -> BoxResult<()> {
Command::Sail { ref copirates } => sail::sail(&copirates_file, copirates, repo_dir)?,
Command::Copirate { ref cmd } => {
match cmd {
CopirateSubcommand::Add { ref initials, ref name, ref email } => copirate::add(&copirates_file, initials, name, email)?,
CopirateSubcommand::Remove { ref initials } => copirate::remove(&copirates_file, initials)?,
CopirateSubcommand::Add {
ref initials,
ref name,
ref email,
} => copirate::add(&copirates_file, initials, name, email)?,
CopirateSubcommand::Remove { ref initials } => {
copirate::remove(&copirates_file, initials)?
}
};
}

Expand Down

0 comments on commit d2e46cb

Please sign in to comment.