Skip to content

Commit

Permalink
feedback:optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashad Alston authored and Rashad Alston committed Jun 2, 2022
1 parent a3b7fd9 commit a20b676
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions forc/src/ops/forc_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,13 @@ pub fn init(command: InitCommand) -> Result<()> {
))
}

let project_name = {
if let Some(name) = command.name {
name
} else {
let dir = project_dir
.file_stem()
.context("Failed to infer project name from directory name.");

match dir {
Ok(d) => d.to_string_lossy().to_string(),
Err(e) => anyhow::bail!("Failed to infer get current directory name: '{}'", e),
}
}
let project_name = match command.name {
Some(name) => name,
None => project_dir
.file_stem()
.context("Failed to infer project name from directory name.")?
.to_string_lossy()
.into_owned(),
};

validate_name(&project_name, "project name")?;
Expand Down

0 comments on commit a20b676

Please sign in to comment.