Skip to content

Commit 9ff4dae

Browse files
Add option to clone local repos (#119)
Co-authored-by: matcool <[email protected]>
1 parent 0130d9c commit 9ff4dae

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

src/template.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,15 @@ fn create_template(template: CreateTemplate) {
4242
} else if template.template.is_empty() {
4343
("geode-sdk/example-mod", "main")
4444
} else {
45-
(
46-
"geode-sdk/example-mod",
47-
match template.template.to_ascii_lowercase().as_str() {
48-
"default" => "main",
49-
"minimal" => "minimal",
50-
"custom layer" => "custom-layer",
51-
_ => {
52-
warn!("Invalid template name, using default template");
53-
"main"
54-
}
55-
},
56-
)
45+
(template.template.as_str(), "main")
5746
};
5847

48+
info!("Cloning {}", used_template);
49+
5950
// Clone repository
6051
RepoBuilder::new()
6152
.branch(branch)
62-
.clone(
63-
format!("https://github.com/{}", used_template).as_str(),
64-
&template.project_location,
65-
)
53+
.clone(used_template, &template.project_location)
6654
.nice_unwrap("Unable to clone repository");
6755

6856
if fs::remove_dir_all(template.project_location.join(".git")).is_err() {
@@ -187,13 +175,20 @@ pub fn build_template(location: Option<PathBuf>) {
187175
let template_options = [
188176
(
189177
"Default - Simple mod that adds a button to the main menu.",
190-
"",
178+
"https://github.com/geode-sdk/example-mod",
191179
),
192180
(
193181
"Minimal - Minimal mod with only the bare minimum to compile.",
194-
"minimal",
182+
"https://github.com/geode-sdk/example-mod@minimal",
183+
),
184+
(
185+
"GitHub Repository - Use your own custom template from github.",
186+
"",
187+
),
188+
(
189+
"Local Repository - Mod template from your own local git repository.",
190+
"",
195191
),
196-
("Other..", ""),
197192
];
198193

199194
let template_index = dialoguer::Select::with_theme(&dialoguer::theme::ColorfulTheme::default())
@@ -209,11 +204,18 @@ pub fn build_template(location: Option<PathBuf>) {
209204
.nice_unwrap("Unable to get template")
210205
.unwrap_or(0);
211206

212-
let template = if template_index == template_options.len() - 1 {
207+
let template = if template_index == template_options.len() - 2 {
213208
println!();
214209
info!("Here you can use any github repository");
215210
info!("Use this syntax: 'user/repo' or 'user/repo@branch'");
216-
ask_value("Template", Some(""), false)
211+
format!("https://github.com/{}", ask_value("Template", None, true))
212+
} else if template_index == template_options.len() - 1 {
213+
println!();
214+
info!("Here you can use any local git repository");
215+
info!("Please provide a local path to clone the repository from");
216+
info!("It can be either a relative or a full path");
217+
info!("Use this syntax: '/path/to/repo' or '/path/to/repo@branch'");
218+
ask_value("Template", None, true)
217219
} else {
218220
template_options[template_index].1.to_string()
219221
};

0 commit comments

Comments
 (0)