Skip to content

Commit cbe9e94

Browse files
cacama-valvatadetjensrobert
authored andcommitted
changed structs to upper pascal case
1 parent 5b9b11e commit cbe9e94

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/commands/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::init::{self as init, templatize_init};
77
use crate::{access_handlers::frontend, commands::deploy};
88

99
pub fn run(_interactive: &bool, _blank: &bool) {
10-
let options: init::init_vars;
10+
let options: init::InitVars;
1111

1212
if *_interactive {
1313
options = match init::interactive_init() {

src/init/mod.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod templates;
88
pub mod example_values;
99

1010
#[derive(serde::Serialize)]
11-
pub struct init_vars {
11+
pub struct InitVars {
1212
pub flag_regex: String,
1313
pub registry_domain: String,
1414
pub registry_build_user: String,
@@ -18,18 +18,18 @@ pub struct init_vars {
1818
pub defaults_difficulty: String,
1919
pub defaults_resources_cpu: String,
2020
pub defaults_resources_memory: String,
21-
pub points: Vec<points>,
22-
pub profiles: Vec<profile>,
21+
pub points: Vec<Points>,
22+
pub profiles: Vec<Profile>,
2323
}
2424

2525
#[derive(Clone, serde::Serialize)]
26-
pub struct points {
26+
pub struct Points {
2727
pub difficulty: String,
2828
pub min: String,
2929
pub max: String,
3030
}
3131

32-
impl fmt::Display for points {
32+
impl fmt::Display for Points {
3333
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3434
write!(
3535
f,
@@ -40,7 +40,7 @@ impl fmt::Display for points {
4040
}
4141

4242
#[derive(serde::Serialize)]
43-
pub struct profile {
43+
pub struct Profile {
4444
pub profile_name: String,
4545
pub frontend_url: String,
4646
pub frontend_token: String,
@@ -53,13 +53,13 @@ pub struct profile {
5353
pub s3_secretaccesskey: String,
5454
}
5555

56-
pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
56+
pub fn interactive_init() -> inquire::error::InquireResult<InitVars> {
5757
println!("For all prompts below, simply press Enter to leave blank.");
5858
println!("All fields that can be set in rcds.yaml can also be set via environment variables.");
5959

60-
let points_ranks_reference: Vec<points>;
60+
let points_ranks_reference: Vec<Points>;
6161

62-
let options = init_vars {
62+
let options = InitVars {
6363
flag_regex: {
6464
//TODO:
6565
// - also provide regex examples in help
@@ -116,9 +116,9 @@ pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
116116
.with_default(false)
117117
.prompt()?;
118118
println!("Challenge points are dynamic. For a static challenge, simply set minimum and maximum points to the same value.");
119-
let mut points_ranks: Vec<points> = Vec::new();
119+
let mut points_ranks: Vec<Points> = Vec::new();
120120
while again {
121-
let points_obj = points {
121+
let points_obj = Points {
122122
difficulty: {
123123
inquire::Text::new("Difficulty class:")
124124
.with_validator(inquire::required!("Please provide a name."))
@@ -130,7 +130,7 @@ pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
130130
min: {
131131
inquire::CustomType::<u64>::new("Minimum points:")
132132
.with_error_message("Please type a valid number.") // default parser calls std::u64::from_str
133-
.with_help_message("Challenge points are dynamic. The minimum number of points that challenges within this difficulty class are worth.")
133+
.with_help_message("The minimum number of points that challenges within this difficulty class are worth.")
134134
.with_placeholder(example_values::POINTS_MIN)
135135
.prompt()?
136136
.to_string()
@@ -196,15 +196,15 @@ pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
196196
profiles: {
197197
println!("You can define several environment profiles below.");
198198

199-
let mut again = inquire::Confirm::new("Do you want to provide a profile?")
199+
let mut again = inquire::Confirm::new("Do you want to provide a Profile?")
200200
.with_default(false)
201201
.prompt()?;
202-
let mut profiles: Vec<profile> = Vec::new();
202+
let mut profiles: Vec<Profile> = Vec::new();
203203
while again {
204-
let prof = profile {
204+
let prof = Profile {
205205
profile_name: {
206206
inquire::Text::new("Profile name:")
207-
.with_help_message("The name of the deployment profile. One profile named \"default\" is recommended. You can add additional profiles.")
207+
.with_help_message("The name of the deployment Profile. One Profile named \"default\" is recommended. You can add additional profiles.")
208208
.with_placeholder(example_values::PROFILES_PROFILE_NAME)
209209
.prompt()?
210210
},
@@ -267,7 +267,7 @@ pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
267267
};
268268
profiles.push(prof);
269269

270-
again = inquire::Confirm::new("Do you want to provide another profile?")
270+
again = inquire::Confirm::new("Do you want to provide another Profile?")
271271
.with_default(false)
272272
.prompt()?;
273273
}
@@ -277,8 +277,8 @@ pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
277277
return Ok(options);
278278
}
279279

280-
pub fn blank_init() -> init_vars {
281-
return init_vars {
280+
pub fn blank_init() -> InitVars {
281+
return InitVars {
282282
flag_regex: String::new(),
283283
registry_domain: String::new(),
284284
registry_build_user: String::new(),
@@ -288,12 +288,12 @@ pub fn blank_init() -> init_vars {
288288
defaults_difficulty: String::new(),
289289
defaults_resources_cpu: String::new(),
290290
defaults_resources_memory: String::new(),
291-
points: vec![points {
291+
points: vec![Points {
292292
difficulty: String::new(),
293293
min: String::new(),
294294
max: String::new(),
295295
}],
296-
profiles: vec![profile {
296+
profiles: vec![Profile {
297297
profile_name: String::from(example_values::PROFILES_PROFILE_NAME),
298298
frontend_url: String::new(),
299299
frontend_token: String::new(),
@@ -308,8 +308,8 @@ pub fn blank_init() -> init_vars {
308308
};
309309
}
310310

311-
pub fn example_init() -> init_vars {
312-
return init_vars {
311+
pub fn example_init() -> InitVars {
312+
return InitVars {
313313
flag_regex: String::from(example_values::FLAG_REGEX), // TODO: do that wildcard in the most common regex flavor since Rust regex supports multiple styles
314314
registry_domain: String::from(example_values::REGISTRY_DOMAIN),
315315
registry_build_user: String::from(example_values::REGISTRY_BUILD_USER),
@@ -320,18 +320,18 @@ pub fn example_init() -> init_vars {
320320
defaults_resources_cpu: String::from(example_values::DEFAULTS_RESOURCES_CPU),
321321
defaults_resources_memory: String::from(example_values::DEFAULTS_RESOURCES_MEMORY),
322322
points: vec![
323-
points {
323+
Points {
324324
difficulty: String::from(example_values::POINTS_DIFFICULTY),
325325
min: String::from(example_values::POINTS_MIN),
326326
max: String::from(example_values::POINTS_MAX),
327327
},
328-
points {
328+
Points {
329329
difficulty: String::from("2"),
330330
min: String::from("1"),
331331
max: String::from("1337"),
332332
},
333333
],
334-
profiles: vec![profile {
334+
profiles: vec![Profile {
335335
profile_name: String::from(example_values::PROFILES_PROFILE_NAME),
336336
frontend_url: String::from(example_values::PROFILES_FRONTEND_URL),
337337
frontend_token: String::from(example_values::PROFILES_FRONTEND_TOKEN),
@@ -346,7 +346,7 @@ pub fn example_init() -> init_vars {
346346
};
347347
}
348348

349-
pub fn templatize_init(options: init_vars) -> String {
349+
pub fn templatize_init(options: InitVars) -> String {
350350
let filled_template = minijinja::render!(templates::RCDS, options);
351351
return filled_template;
352352
}

0 commit comments

Comments
 (0)