diff options
Diffstat (limited to 'src/confirm_abort/mod.rs')
-rw-r--r-- | src/confirm_abort/mod.rs | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/confirm_abort/mod.rs b/src/confirm_abort/mod.rs index b91f7bc..2db9175 100644 --- a/src/confirm_abort/mod.rs +++ b/src/confirm_abort/mod.rs @@ -1,4 +1,44 @@ -#[allow(clippy::module_inception)] -mod confirm_abort; +use crate::git_interactive::GitInteractive; +use crate::input::input_handler::InputHandler; +use crate::input::Input; +use crate::process::exit_status::ExitStatus; +use crate::process::handle_input_result::{HandleInputResult, HandleInputResultBuilder}; +use crate::process::process_module::ProcessModule; +use crate::process::state::State; +use crate::view::View; -pub use self::confirm_abort::ConfirmAbort; +pub(crate) struct ConfirmAbort {} + +impl ProcessModule for ConfirmAbort { + fn handle_input( + &mut self, + input_handler: &InputHandler, + git_interactive: &mut GitInteractive, + _view: &View, + ) -> HandleInputResult + { + let input = input_handler.get_confirm(); + let mut result = HandleInputResultBuilder::new(input); + match input { + Input::Yes => { + git_interactive.clear(); + result = result.exit_status(ExitStatus::Good).state(State::Exiting); + }, + Input::No => { + result = result.state(State::List(false)); + }, + _ => {}, + } + result.build() + } + + fn render(&self, view: &View, _git_interactive: &GitInteractive) { + view.draw_confirm("Are you sure you want to abort"); + } +} + +impl ConfirmAbort { + pub(crate) fn new() -> Self { + Self {} + } +} |