diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2023-10-01 00:00:00 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2023-10-01 00:00:00 +0100 |
| commit | 6e9245542f070c39a1975f0d53d88913c4ac667d (patch) | |
| tree | 835c1d3db05f76f437c5d8ebc5591f1796cdab60 /src/cli_interactor.rs | |
| parent | aa48a626c08cec353d5563a8831239d2e69c9f3d (diff) | |
feat(prs-create) find commits and create events
- identify commits
- create pull request event
- create patch events
Diffstat (limited to 'src/cli_interactor.rs')
| -rw-r--r-- | src/cli_interactor.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/cli_interactor.rs b/src/cli_interactor.rs index d7de087..cf6e3d0 100644 --- a/src/cli_interactor.rs +++ b/src/cli_interactor.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use anyhow::Result; | 1 | use anyhow::Result; |
| 2 | use dialoguer::{theme::ColorfulTheme, Input, Password}; | 2 | use dialoguer::{theme::ColorfulTheme, Confirm, Input, Password}; |
| 3 | #[cfg(test)] | 3 | #[cfg(test)] |
| 4 | use mockall::*; | 4 | use mockall::*; |
| 5 | 5 | ||
| @@ -12,6 +12,7 @@ pub struct Interactor { | |||
| 12 | pub trait InteractorPrompt { | 12 | pub trait InteractorPrompt { |
| 13 | fn input(&self, parms: PromptInputParms) -> Result<String>; | 13 | fn input(&self, parms: PromptInputParms) -> Result<String>; |
| 14 | fn password(&self, parms: PromptPasswordParms) -> Result<String>; | 14 | fn password(&self, parms: PromptPasswordParms) -> Result<String>; |
| 15 | fn confirm(&self, params: PromptConfirmParms) -> Result<bool>; | ||
| 15 | } | 16 | } |
| 16 | impl InteractorPrompt for Interactor { | 17 | impl InteractorPrompt for Interactor { |
| 17 | fn input(&self, parms: PromptInputParms) -> Result<String> { | 18 | fn input(&self, parms: PromptInputParms) -> Result<String> { |
| @@ -29,6 +30,13 @@ impl InteractorPrompt for Interactor { | |||
| 29 | let pass: String = p.interact()?; | 30 | let pass: String = p.interact()?; |
| 30 | Ok(pass) | 31 | Ok(pass) |
| 31 | } | 32 | } |
| 33 | fn confirm(&self, params: PromptConfirmParms) -> Result<bool> { | ||
| 34 | let confirm: bool = Confirm::with_theme(&self.theme) | ||
| 35 | .with_prompt(params.prompt) | ||
| 36 | .default(params.default) | ||
| 37 | .interact()?; | ||
| 38 | Ok(confirm) | ||
| 39 | } | ||
| 32 | } | 40 | } |
| 33 | 41 | ||
| 34 | #[derive(Default)] | 42 | #[derive(Default)] |
| @@ -59,3 +67,20 @@ impl PromptPasswordParms { | |||
| 59 | self | 67 | self |
| 60 | } | 68 | } |
| 61 | } | 69 | } |
| 70 | |||
| 71 | #[derive(Default)] | ||
| 72 | pub struct PromptConfirmParms { | ||
| 73 | pub prompt: String, | ||
| 74 | pub default: bool, | ||
| 75 | } | ||
| 76 | |||
| 77 | impl PromptConfirmParms { | ||
| 78 | pub fn with_prompt<S: Into<String>>(mut self, prompt: S) -> Self { | ||
| 79 | self.prompt = prompt.into(); | ||
| 80 | self | ||
| 81 | } | ||
| 82 | pub fn with_default(mut self, default: bool) -> Self { | ||
| 83 | self.default = default; | ||
| 84 | self | ||
| 85 | } | ||
| 86 | } | ||