requestty/src/lib.rs
Lutetium-Vanadium 818e2b54ee first question impl
There are a lot of things to do, but everything renders well
2021-04-10 17:27:14 +05:30

37 lines
756 B
Rust

// FIXME: remove this
#![allow(dead_code)]
mod answer;
mod error;
pub mod question;
pub use answer::{Answer, ExpandItem, ListItem};
pub use question::{Choice, Choice::Separator, Question};
pub struct Inquisition {
questions: Vec<Question>,
}
impl Inquisition {
pub fn new(questions: Vec<Question>) -> Self {
Inquisition { questions }
}
pub fn add_question(&mut self, question: Question) {
self.questions.push(question)
}
pub fn prompt(self) -> PromptModule {
PromptModule {
answers: Vec::with_capacity(self.questions.len()),
questions: self.questions,
}
}
}
// TODO: ask questions
pub struct PromptModule {
questions: Vec<Question>,
answers: Vec<Answer>,
}