-
Notifications
You must be signed in to change notification settings - Fork 151
Optional input API #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Back here 2yrs later, trying again to switch from promptly to dialoguer. Anyways, I still want to have a "skippable" form field, but I don't know how I can achieve this. fn prompt_opt(msg: &str) -> AtomicResult<Option<String>> {
dialoguer::Input::new()
.with_prompt(msg)
.interact()
.map(|s: String| if s.is_empty() { None } else { Some(s) })
.map_err(|e| format!("Error while prompting: {}", e).into())
} This seemed sensible, but if I press enter when the string is empty nothing happens. I'm assuming I'm missing something obvious! |
I guess you are missing |
Try |
Ah, right - that too. |
Closing this until further response that the suggestion doesn't work. |
Hi there! Thanks for creating this :)
I have some input fields that are optional. I'd like to have an API similar to this:
Maybe I'm missing something in the docs, but I don't really see how I should achieve these optional inputs.
I know you can use
.allow_empty
, but that doesn't really work for things like numbers.The text was updated successfully, but these errors were encountered: