Skip to content

Commit fb4b530

Browse files
fix: fmt errors
1 parent 409caee commit fb4b530

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

loco-new/src/bin/main.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ use clap::{Parser, Subcommand};
99
use duct::cmd;
1010
use loco::{
1111
generator::{
12-
executer,
13-
extract_default_template,
14-
extract_tree_template,
15-
read_file_contents,
16-
Generator
12+
executer, extract_default_template, extract_tree_template, read_file_contents, Generator,
1713
},
1814
settings::Settings,
1915
wizard, Result, OS,
@@ -136,12 +132,8 @@ fn main() -> Result<()> {
136132
"base_template"
137133
};
138134

139-
let settings = Settings::from_wizard(
140-
&app_name,
141-
&prompt_template_dir,
142-
&user_selection,
143-
os
144-
);
135+
let settings =
136+
Settings::from_wizard(&app_name, &prompt_template_dir, &user_selection, os);
145137
let template_path = Path::new(settings.template_dir.as_str());
146138

147139
let generator_tmp_folder = if let Some(_) = template_dir {
@@ -159,20 +151,19 @@ fn main() -> Result<()> {
159151
temp_to.root.as_path(),
160152
);
161153

162-
163154
if let Ok(path) = env::var("LOCO_DEV_MODE_PATH") {
164155
println!("⚠️ NOTICE: working in dev mode, pointing to local Loco on '{path}'");
165156
}
166157

167158
let dynamic_script_owner: Option<String> = if let Some(path) = template_dir {
168159
let setup_filepath = format!("{}/setup.rhai", path); // Your line 168
169-
160+
170161
// Read the file and store the *owned String* in our `Option`.
171162
// We return the `Result` and `?` will propagate the error.
172163
Some(read_file_contents(setup_filepath.as_str())?)
173164
} else {
174165
None
175-
};
166+
};
176167

177168
// 2. NOW, we can safely create the `script` borrow.
178169
let script = if let Some(ref contents) = dynamic_script_owner {
@@ -182,10 +173,11 @@ fn main() -> Result<()> {
182173
} else {
183174
// Otherwise, `script` gets the static fallback.
184175
// (I am guessing this is what your `else` block had)
185-
include_str!("../../setup.rhai")
176+
include_str!("../../setup.rhai")
186177
};
187178

188-
let res = match Generator::new(Arc::new(executor), settings).run_from_script(script) {
179+
let res = match Generator::new(Arc::new(executor), settings).run_from_script(script)
180+
{
189181
Ok(()) => {
190182
std::fs::create_dir_all(&to)?;
191183
let copy_options = fs_extra::dir::CopyOptions::new().content_only(true);

loco-new/src/generator/mod.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::sync::Arc;
88

99
use fs_extra::dir::CopyOptions;
1010
use include_dir::{include_dir, Dir};
11-
use tree_fs::TreeBuilder;
1211
use rhai::{
1312
export_module, exported_module,
1413
plugin::{
@@ -17,6 +16,7 @@ use rhai::{
1716
},
1817
Engine, Scope,
1918
};
19+
use tree_fs::TreeBuilder;
2020

2121
use crate::wizard::AssetsOption;
2222
use crate::{settings, OS};
@@ -48,7 +48,7 @@ pub fn extract_tree_template(source_path: &Path) -> std::io::Result<tree_fs::Tre
4848
format!(
4949
"Source directory '{}' not found or is not a directory",
5050
source_path.display()
51-
)
51+
),
5252
));
5353
}
5454

@@ -58,15 +58,19 @@ pub fn extract_tree_template(source_path: &Path) -> std::io::Result<tree_fs::Tre
5858
// 3. Prepare copy options
5959
// We use `content_only` to mimic the `extract` behavior.
6060
// This copies the *contents* of `source_path`, not the `source_path` folder itself.
61-
let options = CopyOptions::new()
62-
.content_only(true);
61+
let options = CopyOptions::new().content_only(true);
6362

6463
// 4. Copies files from the dynamic `source_path` into the temporary directory
65-
fs_extra::dir::copy(source_path, &generator_tmp_folder.root, &options)
66-
.map_err(|e| std::io::Error::new(
64+
fs_extra::dir::copy(source_path, &generator_tmp_folder.root, &options).map_err(|e| {
65+
std::io::Error::new(
6766
std::io::ErrorKind::Other,
68-
format!("Failed to copy template from '{}': {}", source_path.display(), e)
69-
))?;
67+
format!(
68+
"Failed to copy template from '{}': {}",
69+
source_path.display(),
70+
e
71+
),
72+
)
73+
})?;
7074

7175
// 5. Returns a handle to the populated temporary directory (same as before)
7276
return Ok(generator_tmp_folder);

0 commit comments

Comments
 (0)