diff options
| -rw-r--r-- | Cargo.lock | 5 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/lib/cli_interactor.rs | 27 | ||||
| -rw-r--r-- | test_utils/Cargo.toml | 2 |
4 files changed, 18 insertions, 18 deletions
| @@ -504,13 +504,14 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" | |||
| 504 | 504 | ||
| 505 | [[package]] | 505 | [[package]] |
| 506 | name = "dialoguer" | 506 | name = "dialoguer" |
| 507 | version = "0.10.4" | 507 | version = "0.11.0" |
| 508 | source = "registry+https://github.com/rust-lang/crates.io-index" | 508 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 509 | checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" | 509 | checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" |
| 510 | dependencies = [ | 510 | dependencies = [ |
| 511 | "console", | 511 | "console", |
| 512 | "shell-words", | 512 | "shell-words", |
| 513 | "tempfile", | 513 | "tempfile", |
| 514 | "thiserror 1.0.69", | ||
| 514 | "zeroize", | 515 | "zeroize", |
| 515 | ] | 516 | ] |
| 516 | 517 | ||
| @@ -18,7 +18,7 @@ auth-git2 = "0.5.4" | |||
| 18 | chacha20poly1305 = "0.10.1" | 18 | chacha20poly1305 = "0.10.1" |
| 19 | clap = { version = "4.3.19", features = ["derive"] } | 19 | clap = { version = "4.3.19", features = ["derive"] } |
| 20 | console = "0.15.7" | 20 | console = "0.15.7" |
| 21 | dialoguer = "0.10.4" | 21 | dialoguer = "0.11.0" |
| 22 | directories = "6.0.0" | 22 | directories = "6.0.0" |
| 23 | futures = "0.3.28" | 23 | futures = "0.3.28" |
| 24 | git2 = "0.20.2" | 24 | git2 = "0.20.2" |
diff --git a/src/lib/cli_interactor.rs b/src/lib/cli_interactor.rs index 1b74101..8fca81d 100644 --- a/src/lib/cli_interactor.rs +++ b/src/lib/cli_interactor.rs | |||
| @@ -19,20 +19,21 @@ pub trait InteractorPrompt { | |||
| 19 | } | 19 | } |
| 20 | impl InteractorPrompt for Interactor { | 20 | impl InteractorPrompt for Interactor { |
| 21 | fn input(&self, parms: PromptInputParms) -> Result<String> { | 21 | fn input(&self, parms: PromptInputParms) -> Result<String> { |
| 22 | let mut input = Input::with_theme(&self.theme); | 22 | let mut input = Input::with_theme(&self.theme) |
| 23 | input.with_prompt(parms.prompt).allow_empty(parms.optional); | 23 | .with_prompt(parms.prompt) |
| 24 | .allow_empty(parms.optional) | ||
| 25 | .report(parms.report); | ||
| 24 | if !parms.default.is_empty() { | 26 | if !parms.default.is_empty() { |
| 25 | input.default(parms.default); | 27 | input = input.default(parms.default); |
| 26 | } | 28 | } |
| 27 | input.report(parms.report); | ||
| 28 | Ok(input.interact_text()?) | 29 | Ok(input.interact_text()?) |
| 29 | } | 30 | } |
| 30 | fn password(&self, parms: PromptPasswordParms) -> Result<String> { | 31 | fn password(&self, parms: PromptPasswordParms) -> Result<String> { |
| 31 | let mut p = Password::with_theme(&self.theme); | 32 | let mut p = Password::with_theme(&self.theme) |
| 32 | p.with_prompt(parms.prompt); | 33 | .with_prompt(parms.prompt) |
| 33 | p.report(parms.report); | 34 | .report(parms.report); |
| 34 | if parms.confirm { | 35 | if parms.confirm { |
| 35 | p.with_confirmation("confirm password", "passwords didnt match..."); | 36 | p = p.with_confirmation("confirm password", "passwords didnt match..."); |
| 36 | } | 37 | } |
| 37 | let pass: String = p.interact()?; | 38 | let pass: String = p.interact()?; |
| 38 | Ok(pass) | 39 | Ok(pass) |
| @@ -45,27 +46,25 @@ impl InteractorPrompt for Interactor { | |||
| 45 | Ok(confirm) | 46 | Ok(confirm) |
| 46 | } | 47 | } |
| 47 | fn choice(&self, parms: PromptChoiceParms) -> Result<usize> { | 48 | fn choice(&self, parms: PromptChoiceParms) -> Result<usize> { |
| 48 | let mut choice = dialoguer::Select::with_theme(&self.theme); | 49 | let mut choice = dialoguer::Select::with_theme(&self.theme) |
| 49 | choice | ||
| 50 | .with_prompt(parms.prompt) | 50 | .with_prompt(parms.prompt) |
| 51 | .report(parms.report) | 51 | .report(parms.report) |
| 52 | .items(&parms.choices); | 52 | .items(&parms.choices); |
| 53 | if let Some(default) = parms.default { | 53 | if let Some(default) = parms.default { |
| 54 | if std::env::var("NGITTEST").is_err() { | 54 | if std::env::var("NGITTEST").is_err() { |
| 55 | choice.default(default); | 55 | choice = choice.default(default); |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | choice.interact().context("failed to get choice") | 58 | choice.interact().context("failed to get choice") |
| 59 | } | 59 | } |
| 60 | fn multi_choice(&self, parms: PromptMultiChoiceParms) -> Result<Vec<usize>> { | 60 | fn multi_choice(&self, parms: PromptMultiChoiceParms) -> Result<Vec<usize>> { |
| 61 | // the colorful theme is not very clear so falling back to default | 61 | // the colorful theme is not very clear so falling back to default |
| 62 | let mut choice = dialoguer::MultiSelect::default(); | 62 | let mut choice = dialoguer::MultiSelect::default() |
| 63 | choice | ||
| 64 | .with_prompt(parms.prompt) | 63 | .with_prompt(parms.prompt) |
| 65 | .report(parms.report) | 64 | .report(parms.report) |
| 66 | .items(&parms.choices); | 65 | .items(&parms.choices); |
| 67 | if let Some(defaults) = parms.defaults { | 66 | if let Some(defaults) = parms.defaults { |
| 68 | choice.defaults(&defaults); | 67 | choice = choice.defaults(&defaults); |
| 69 | } | 68 | } |
| 70 | choice.interact().context("failed to get choice") | 69 | choice.interact().context("failed to get choice") |
| 71 | } | 70 | } |
diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index 0888aa6..2001733 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml | |||
| @@ -6,7 +6,7 @@ edition = "2021" | |||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | anyhow = "1.0.75" | 7 | anyhow = "1.0.75" |
| 8 | assert_cmd = "2.0.12" | 8 | assert_cmd = "2.0.12" |
| 9 | dialoguer = "0.10.4" | 9 | dialoguer = "0.11.0" |
| 10 | directories = "6.0.0" | 10 | directories = "6.0.0" |
| 11 | futures = "0.3.28" | 11 | futures = "0.3.28" |
| 12 | git2 = "0.20.2" | 12 | git2 = "0.20.2" |