moon add wangmingfa/promptx/inquirerpub enum QuestionType {
Input
Confirm
List
RawList
Expand
Checkbox
Password
Editor
}
pub enum AnswerValue {
StringValue(String)
BoolValue(Bool)
ArrayValue(Array[String])
IntValue(Int)
}
pub type Answer = Map[String, AnswerValue]
pub struct Question {
question_type : QuestionType
question_name : String
question_message : String
question_default : AnswerValue?
question_choices : Array[String]?
}moon test inquirertest {
let map = { 3: "three", 8: "eight", 1: "one" }
@test.assert_eq(map.get(2), None)
@test.assert_eq(map.get(3), Some("three"))
map.set(3, "updated")
@test.assert_eq(map.get(3), Some("updated"))
}pub struct Question {
question_type : QuestionType
question_name : String
question_message : String
question_default : AnswerValue?
question_choices : Array[String]?
}fn checkbox(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue?) -> Questionfn confirm(question_name~ : String, question_message~ : String, question_default? : AnswerValue?) -> Questionfn editor(question_name~ : String, question_message~ : String, question_default? : AnswerValue?) -> Questionfn expand(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue?) -> Questionfn input(question_name~ : String, question_message~ : String, question_default? : AnswerValue?) -> Questionfn list(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue?) -> Questionfn move_cursor_down(_n : Int) -> Unitfn move_cursor_to_start() -> Unitfn move_cursor_up(_n : Int) -> Unitfn password(question_name~ : String, question_message~ : String, question_default? : AnswerValue?) -> Questionfn rawlist(question_name~ : String, question_message~ : String, question_choices~ : Array[String], question_default? : AnswerValue?) -> Questionfn render_checkbox_item(_index : Int, choice : String, checked : Bool) -> Stringfn safe_parse_int(s : String) -> Int?