Skip to content

Commit a13a620

Browse files
committed
added type key for config
1 parent eef3948 commit a13a620

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

src/initialize_everything.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ const CONTENT_README: &str = "# A mod about {title}";
77
const CONTENT_JSON_CONFIG: &str = r#"{
88
"isOpenSource": "{is_open_source}",
99
"canMessWithComputer": "{can_mess_with_computer}",
10-
10+
"type": "{type}",
11+
1112
"title": "{title}",
1213
"description": "{description}",
1314
"madeBy": "{made_by}",
14-
15+
1516
"downloadURL": "{download_url}",
1617
"externalURL": "{external_url}",
1718
"githubURL": "{github_url}",
@@ -21,6 +22,7 @@ const CONTENT_JSON_CONFIG: &str = r#"{
2122
pub fn init_yes(
2223
path_to_logo: &str,
2324
path_to_banner: &str,
25+
what_type: Vec<i32>,
2426
is_open_source: &str,
2527
can_mess_with_computer: &str,
2628
title: &str,
@@ -35,7 +37,7 @@ pub fn init_yes(
3537
// === === === config.json // readme.md === === ===
3638
let formatted_string = format!("{}{}", path_to_export, ".solar-engine");
3739
let extended_path = Path::new(&formatted_string);
38-
40+
3941
if extended_path.exists() {
4042
let path_exists_prompt = boolean(&format!("`{}` {}", path_to_export.bright_black(), "path exists. Do you wish to delete it?".yellow()));
4143

@@ -49,6 +51,15 @@ pub fn init_yes(
4951
fs::create_dir(extended_path).unwrap();
5052
}
5153

54+
let mut returned_type_shi: &str = "Other";
55+
for num in what_type {
56+
if num == 1 {
57+
returned_type_shi = "Scripts";
58+
} else if num == 2 {
59+
returned_type_shi = "Mods";
60+
}
61+
}
62+
5263
let populated_json = CONTENT_JSON_CONFIG
5364
.replace("{is_open_source}", is_open_source)
5465
.replace("{can_mess_with_computer}", can_mess_with_computer)
@@ -58,11 +69,12 @@ pub fn init_yes(
5869
.replace("{download_url}", download_url)
5970
.replace("{external_url}", external_url)
6071
.replace("{github_url}", github_url)
61-
.replace("{made_by_url}", made_by_url);
62-
72+
.replace("{made_by_url}", made_by_url)
73+
.replace("{type}", returned_type_shi);
74+
6375
let formatted_readme = CONTENT_README
6476
.replace("{title}", title);
65-
77+
6678
create_file(&format!("{}/readme.md", formatted_string), &formatted_readme);
6779
create_file(&format!("{}/config.json", formatted_string), &populated_json);
6880

@@ -79,4 +91,4 @@ pub fn init_yes(
7991
fn create_file(path_to: &str, content: &str) {
8092
fs::write(path_to, content).unwrap();
8193
println!("{} {}", "Created".green(), path_to.to_string().white());
82-
}
94+
}

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
mod initialize_everything;
22
use dvs_interactive_cli_rs::boolean;
33
use dvs_interactive_cli_rs::input;
4+
use dvs_interactive_cli_rs::choices;
45

56
fn main() {
67
let path_to_logo = input("Path to mod/script logo", &true, "FULL PATH.");
78
let path_to_banner = input("Path to mod/script banner", &true, "FULL PATH.");
9+
let what_type = choices("What type is it?", &["Scripts", "Mod"].as_slice(), &false, &true);
810
let is_open_source = boolean("Is it open source?");
911
let can_mess_with_computer = boolean("Can it mess with your computer?");
1012
let title = input("Input the title of your mod/script", &true, "Your epic cool mod");
@@ -22,6 +24,7 @@ fn main() {
2224
initialize_everything::init_yes(
2325
&path_to_logo,
2426
&path_to_banner,
27+
what_type,
2528
&is_open_source,
2629
&can_mess_with_computer,
2730
&title,

0 commit comments

Comments
 (0)