From b7c24559aa2758820039295ac0f6120dfdec550e Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 15 Feb 2024 10:16:00 +0000 Subject: fix: allow optional description and web also add a default web --- src/cli_interactor.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/cli_interactor.rs') diff --git a/src/cli_interactor.rs b/src/cli_interactor.rs index c6cd4e5..693e9fd 100644 --- a/src/cli_interactor.rs +++ b/src/cli_interactor.rs @@ -19,6 +19,8 @@ impl InteractorPrompt for Interactor { fn input(&self, parms: PromptInputParms) -> Result { let input: String = Input::with_theme(&self.theme) .with_prompt(parms.prompt) + .default(parms.default) + .allow_empty(parms.optional) .interact_text()?; Ok(input) } @@ -51,6 +53,8 @@ impl InteractorPrompt for Interactor { #[derive(Default)] pub struct PromptInputParms { pub prompt: String, + pub default: String, + pub optional: bool, } impl PromptInputParms { @@ -58,6 +62,14 @@ impl PromptInputParms { self.prompt = prompt.into(); self } + pub fn with_default>(mut self, default: S) -> Self { + self.default = default.into(); + self + } + pub fn optional(mut self) -> Self { + self.optional = true; + self + } } #[derive(Default)] -- cgit v1.2.3