Skip to content

Commit

Permalink
feat: add BoolInput to query user for boolean input (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangl-cc authored Nov 24, 2023
1 parent d11ada2 commit c5e8640
Show file tree
Hide file tree
Showing 6 changed files with 372 additions and 142 deletions.
5 changes: 4 additions & 1 deletion config_examples/tasks/daily.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"type": "StartUp",
"params": {
"client_type": "Official",
"start_game_enabled": true
"start_game_enabled": {
"default": true,
"description": "start the game"
}
}
},
{
Expand Down
5 changes: 4 additions & 1 deletion config_examples/tasks/daily.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# startup game
[[tasks]]
type = "StartUp"
params = { client_type = "Official", start_game_enabled = true }

[tasks.params]
client_type = "Official"
start_game_enabled = { default = true, description = "start the game" }

[[tasks]]
type = "Fight"
Expand Down
4 changes: 3 additions & 1 deletion config_examples/tasks/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ tasks:
- type: StartUp
params:
client_type: Official
start_game_enabled: true
start_game_enabled:
default: true
description: start the game
- type: Fight
strategy: merge
variants:
Expand Down
39 changes: 19 additions & 20 deletions maa-cli/src/config/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ mod tests {
mod deserialize_example {
use super::*;

use value::input::{Input, Select};
use value::input::{BoolInput, Input, Select};

use chrono::{NaiveDateTime, NaiveTime, TimeZone, Weekday};

Expand All @@ -361,7 +361,10 @@ mod tests {
TaskType::StartUp,
object!(
"client_type" => "Official",
"start_game_enabled" => true,
"start_game_enabled" => BoolInput::new(
Some(true),
Some("start the game"),
),
),
Strategy::default(),
vec![TaskVariant {
Expand All @@ -383,12 +386,10 @@ mod tests {
TaskVariant {
condition: Condition::Always,
params: object!(
"stage" => Value::InputString(
Input{
default: Some("1-7".to_string()),
description: Some("a stage to fight".to_string()) }
.into(),
)
"stage" => Input {
default: Some("1-7".to_string()),
description: Some("a stage to fight".to_string())
}
),
},
TaskVariant {
Expand All @@ -402,25 +403,23 @@ mod tests {
start: Some(naive_local_datetime(2023, 8, 1, 16, 0, 0)),
end: Some(naive_local_datetime(2023, 8, 21, 3, 59, 59)),
},
params: object!("stage" => Value::InputString(
Select {
alternatives: vec![
"SL-6".to_string(),
"SL-7".to_string(),
"SL-8".to_string(),
],
description: Some("a stage to fight in summer event".to_string()),
}
.into(),
)
params: object!(
"stage" => Select {
alternatives: vec![
"SL-6".to_string(),
"SL-7".to_string(),
"SL-8".to_string(),
],
description: Some("a stage to fight in summer event".to_string()),
}
),
},
],
),
Task::new(
TaskType::Mall,
object!(
"shopping" => true,
"shopping" => true,
"credit_fight" => true,
"buy_first" => [
"招聘许可",
Expand Down
Loading

0 comments on commit c5e8640

Please sign in to comment.