Skip to content

Commit 5b9b11e

Browse files
cacama-valvatadetjensrobert
authored andcommitted
init command - allowed difficulty class to be a string instead of a number identifier
1 parent ce58111 commit 5b9b11e

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/init/example_values.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub static REGISTRY_CLUSTER_PASS: &str = "alsofake";
99
pub static DEFAULTS_DIFFICULTY: &str = "1";
1010
pub static DEFAULTS_RESOURCES_CPU: &str = "1";
1111
pub static DEFAULTS_RESOURCES_MEMORY: &str = "500M";
12-
pub static POINTS_DIFFICULTY: &str = "1";
12+
pub static POINTS_DIFFICULTY: &str = "easy";
1313
pub static POINTS_MIN: &str = "200";
1414
pub static POINTS_MAX: &str = "500";
1515
pub static PROFILES_PROFILE_NAME: &str = "default";

src/init/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
8585
.prompt()?
8686
},
8787

88-
// TODO: do we actually want to be in charge of these credentials vs letting the container building utility take care of it?
88+
// TODO: do we actually want to be in charge of these credentials vs expecting the local building utility already be logged in?
8989
registry_build_pass: {
9090
inquire::Password::new("Container registry 'build' password:")
9191
.with_help_message("The password to the 'build' user account") // TODO: could this support username:pat too?
@@ -115,33 +115,29 @@ pub fn interactive_init() -> inquire::error::InquireResult<init_vars> {
115115
let mut again = inquire::Confirm::new("Do you want to provide a difficulty class?")
116116
.with_default(false)
117117
.prompt()?;
118+
println!("Challenge points are dynamic. For a static challenge, simply set minimum and maximum points to the same value.");
118119
let mut points_ranks: Vec<points> = Vec::new();
119120
while again {
120121
let points_obj = points {
121-
// TODO: theres no reason these need to be numbers instead of open strings, e.g. for "easy"
122122
difficulty: {
123-
inquire::CustomType::<u64>::new("Difficulty rank:")
124-
// default parser calls std::u64::from_str
125-
.with_error_message("Please type a valid number.")
126-
.with_help_message("The rank of the difficulty class as an unsigned integer, with lower numbers being \"easier.\"")
123+
inquire::Text::new("Difficulty class:")
124+
.with_validator(inquire::required!("Please provide a name."))
125+
.with_help_message("The name of the difficulty class.")
127126
.with_placeholder(example_values::POINTS_DIFFICULTY)
128127
.prompt()?
129-
.to_string()
130128
},
131129
// TODO: support static-point challenges
132130
min: {
133131
inquire::CustomType::<u64>::new("Minimum points:")
134-
// default parser calls std::u64::from_str
135-
.with_error_message("Please type a valid number.")
132+
.with_error_message("Please type a valid number.") // default parser calls std::u64::from_str
136133
.with_help_message("Challenge points are dynamic. The minimum number of points that challenges within this difficulty class are worth.")
137134
.with_placeholder(example_values::POINTS_MIN)
138135
.prompt()?
139136
.to_string()
140137
},
141138
max: {
142139
inquire::CustomType::<u64>::new("Maximum points:")
143-
// default parser calls std::u64::from_str
144-
.with_error_message("Please type a valid number.")
140+
.with_error_message("Please type a valid number.") // default parser calls std::u64::from_str
145141
.with_help_message("The maximum number of points that challenges within this difficulty class are worth.")
146142
.with_placeholder(example_values::POINTS_MAX)
147143
.prompt()?

0 commit comments

Comments
 (0)