summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs2
-rw-r--r--src/utils/prompt_input.rs74
2 files changed, 0 insertions, 76 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index ecc81aa..8d66470 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -5,7 +5,6 @@ mod crypto;
mod html_to_md;
mod loader;
mod path;
-mod prompt_input;
mod render_prompt;
mod request;
mod spinner;
@@ -18,7 +17,6 @@ pub use self::crypto::*;
pub use self::html_to_md::*;
pub use self::loader::*;
pub use self::path::*;
-pub use self::prompt_input::*;
pub use self::render_prompt::render_prompt;
pub use self::request::*;
pub use self::spinner::*;
diff --git a/src/utils/prompt_input.rs b/src/utils/prompt_input.rs
deleted file mode 100644
index 26343a2..0000000
--- a/src/utils/prompt_input.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-use inquire::{required, validator::Validation, Text};
-
-const MSG_REQUIRED: &str = "This field is required";
-const MSG_OPTIONAL: &str = "Optional field - Press ↵ to skip";
-
-pub fn prompt_input_string(desc: &str, required: bool) -> anyhow::Result<String> {
- let mut text = Text::new(desc);
- if required {
- text = text.with_validator(required!(MSG_REQUIRED))
- } else {
- text = text.with_help_message(MSG_OPTIONAL)
- }
- let text = text.prompt()?;
- Ok(text)
-}
-
-pub fn prompt_input_integer(desc: &str, required: bool) -> anyhow::Result<String> {
- let mut text = Text::new(desc);
- if required {
- text = text.with_validator(|text: &str| {
- let out = if text.is_empty() {
- Validation::Invalid(MSG_REQUIRED.into())
- } else {
- validate_integer(text)
- };
- Ok(out)
- })
- } else {
- text = text
- .with_validator(|text: &str| {
- let out = if text.is_empty() {
- Validation::Valid
- } else {
- validate_integer(text)
- };
- Ok(out)
- })
- .with_help_message(MSG_OPTIONAL)
- }
- let text = text.prompt()?;
- Ok(text)
-}
-
-#[derive(Debug, Clone, Copy)]
-pub enum PromptKind {
- String,
- Integer,
-}
-
-fn validate_integer(text: &str) -> Validation {
- if text.parse::<i32>().is_err() {
- Validation::Invalid("Must be a integer".into())
- } else {
- Validation::Valid
- }
-}
-
-#[derive(Debug)]
-pub struct SelectOption {
- pub value: String,
- pub description: String,
-}
-
-impl SelectOption {
- pub fn new(value: String, description: String) -> Self {
- Self { value, description }
- }
-}
-
-impl std::fmt::Display for SelectOption {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "{} ({})", self.value, self.description)
- }
-}