Skip to content

Commit 61472a3

Browse files
committed
Fix misplaced if/let blocks in project creation functions
1 parent d2ee5d2 commit 61472a3

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

src/languages/c/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ pub fn proj(proj_name: &String) -> Result<(), LionError> {
3030
eprintln!("Failed to create common directories: {}", err);
3131
}
3232

33+
if let Err(error) = fs::DirBuilder::new()
34+
.recursive(true)
35+
.create(format!("{proj_name}/external"))
36+
{
37+
println!("An error occurred while trying to create C project: {error}")
38+
};
3339
Ok(
34-
if let Err(error) = fs::DirBuilder::new()
35-
.recursive(true)
36-
.create(format!("{proj_name}/external"))
37-
{
38-
println!("An error occurred while trying to create C project: {error}")
39-
},
40+
(),
4041
)
4142
}
4243

src/languages/cpp/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ pub fn proj(proj_name: &String) -> Result<(), LionError> {
3131
eprintln!("Failed to create common directories: {}", err);
3232
}
3333

34+
if let Err(error) = fs::DirBuilder::new()
35+
.recursive(true)
36+
.create(format!("{proj_name}/external"))
37+
{
38+
eprintln!("An error occurred while creating C++ project: {error}")
39+
};
3440
Ok(
35-
if let Err(error) = fs::DirBuilder::new()
36-
.recursive(true)
37-
.create(format!("{proj_name}/external"))
38-
{
39-
eprintln!("An error occurred while creating C++ project: {error}")
40-
},
41+
(),
4142
)
4243
}
4344

src/languages/go/mod.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ pub fn dep(dep: &String) -> Result<(), LionError> {
3131
}
3232

3333
pub fn proj(proj_name: &String) -> Result<(), LionError> {
34+
if let Err(error) = Command::new("go")
35+
.arg("mod")
36+
.arg("init")
37+
.arg(format!("./{proj_name}"))
38+
.status()
39+
{
40+
eprintln!("An error occurred while trying to create go project: {error}");
41+
};
3442
Ok(
35-
if let Err(error) = Command::new("go")
36-
.arg("mod")
37-
.arg("init")
38-
.arg(format!("./{proj_name}"))
39-
.status()
40-
{
41-
eprintln!("An error occurred while trying to create go project: {error}");
42-
},
43+
(),
4344
)
4445
}
4546

src/languages/java/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ pub fn run(file_name: &String) -> Result<(), LionError> {
3333
}
3434

3535
pub fn proj(proj_name: &String) -> Result<(), LionError> {
36-
Ok(if let Err(err) = common_dir(proj_name) {
36+
if let Err(err) = common_dir(proj_name) {
3737
eprintln!(
3838
"An error occured while trying to create java project: {}",
3939
err
4040
);
41-
})
41+
};
42+
Ok(())
4243
}
4344

4445
pub fn new(file_name: &String) -> Result<(), LionError> {

src/languages/rust/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ pub fn run(file_name: &String) -> Result<(), LionError> {
2727
}
2828

2929
pub fn proj(proj_name: &String) -> Result<(), LionError> {
30+
if let Err(error) = Command::new("cargo").arg("new").arg(proj_name).status() {
31+
eprintln!("Error while trying to create Rust project: {}", error);
32+
};
3033
Ok(
31-
if let Err(error) = Command::new("cargo").arg("new").arg(proj_name).status() {
32-
eprintln!("Error while trying to create Rust project: {}", error);
33-
},
34+
(),
3435
)
3536
}
3637

0 commit comments

Comments
 (0)