feat: adds prompts
This commit is contained in:
parent
1a138ab54d
commit
ed37b8ccc8
@ -1,41 +1,77 @@
|
|||||||
use crate::{models::{Epic, Story, Status}, io_utils::get_user_input};
|
use crate::{
|
||||||
|
io_utils::get_user_input,
|
||||||
|
models::{Epic, Status, Story},
|
||||||
|
};
|
||||||
|
|
||||||
|
static DELIMITER: &str = "----------------------------";
|
||||||
|
|
||||||
pub struct Prompts {
|
pub struct Prompts {
|
||||||
pub create_epic: Box<dyn Fn() -> Epic>,
|
pub create_epic: Box<dyn Fn() -> Epic>,
|
||||||
pub create_story: Box<dyn Fn() -> Story>,
|
pub create_story: Box<dyn Fn() -> Story>,
|
||||||
pub delete_epic: Box<dyn Fn() -> bool>,
|
pub delete_epic: Box<dyn Fn() -> bool>,
|
||||||
pub delete_story: Box<dyn Fn() -> bool>,
|
pub delete_story: Box<dyn Fn() -> bool>,
|
||||||
pub update_status: Box<dyn Fn() -> Option<Status>>
|
pub update_status: Box<dyn Fn() -> Option<Status>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Prompts {
|
impl Prompts {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
create_epic: Box::new(create_epic_prompt),
|
create_epic: Box::new(create_epic_prompt),
|
||||||
create_story: Box::new(create_story_prompt),
|
create_story: Box::new(create_story_prompt),
|
||||||
delete_epic: Box::new(delete_epic_prompt),
|
delete_epic: Box::new(delete_epic_prompt),
|
||||||
delete_story: Box::new(delete_story_prompt),
|
delete_story: Box::new(delete_story_prompt),
|
||||||
update_status: Box::new(update_status_prompt)
|
update_status: Box::new(update_status_prompt),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_epic_prompt() -> Epic {
|
fn create_epic_prompt() -> Epic {
|
||||||
todo!();
|
println!("{DELIMITER}");
|
||||||
|
println!("Epic Name:");
|
||||||
|
let name = get_user_input();
|
||||||
|
println!("Epic Description:");
|
||||||
|
let description = get_user_input();
|
||||||
|
Epic::new(name, description)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_story_prompt() -> Story {
|
fn create_story_prompt() -> Story {
|
||||||
todo!();
|
println!("{DELIMITER}");
|
||||||
|
println!("Story Name:");
|
||||||
|
let name = get_user_input();
|
||||||
|
println!("Story Description:");
|
||||||
|
let description = get_user_input();
|
||||||
|
Story::new(name, description)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_epic_prompt() -> bool {
|
fn delete_epic_prompt() -> bool {
|
||||||
todo!();
|
static QUESTION: &str = "Are you sure you want to delete this epic? All stories in this epic will also be deleted [Y/n]:";
|
||||||
|
println!("{DELIMITER}");
|
||||||
|
print!("{QUESTION}");
|
||||||
|
let decision = matches!(get_user_input().as_str(), "y" | "Y");
|
||||||
|
println!();
|
||||||
|
decision
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_story_prompt() -> bool {
|
fn delete_story_prompt() -> bool {
|
||||||
todo!();
|
static QUESTION: &str = "Are you sure you want to delete this story? [Y/n]:";
|
||||||
|
println!("{DELIMITER}");
|
||||||
|
print!("{QUESTION}");
|
||||||
|
let decision = matches!(get_user_input().as_str(), "y" | "Y");
|
||||||
|
println!();
|
||||||
|
decision
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_status_prompt() -> Option<Status> {
|
fn update_status_prompt() -> Option<Status> {
|
||||||
todo!();
|
static QUESTION: &str = "New Status (1 - OPEN, 2 - IN-PROGRESS, 3 - RESOLVED, 4 - CLOSED):";
|
||||||
}
|
println!("{DELIMITER}");
|
||||||
|
print!("{QUESTION}");
|
||||||
|
let decision = match get_user_input().as_str() {
|
||||||
|
"1" => Some(Status::Open),
|
||||||
|
"2" => Some(Status::InProgress),
|
||||||
|
"3" => Some(Status::Resolved),
|
||||||
|
"4" => Some(Status::Closed),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
println!();
|
||||||
|
decision
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user