Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First, I have to say thank you for creating Bullet. I am using it to create a menu-driven UI in one of my projects, and it has been wonderful to use.
While using Bullet, I have created several custom prompts and I would love to contribute them back to the project. However, I notice that Bullet currently does not include any external dependencies and implementing my additions would require this to change.
In this PR, I have created a
Date
prompt that extendsInput
. It can parse a date from many different string formats thanks to theparser
module in the python-dateutil package. Please note that this is an extremely mature package, as it was first released in 2003 and is currently managed by the PSF.I also included a
wrap_text
function that makes printing any arbitrarily long string to the console much better. Using themax_len
argument, it returns a new string that is wrapped and does not break in the middle of words. It is used when the value entered by the user failed to parse, since the error message that is displayed is somewhat verbose.If no external dependencies is a hard-requirement, please feel free to close this PR. If it is not, I will submit additional PRs with other prompts I have created. Thank you again for creating this awesome utility!
Basic Usage
Output
Error Handling, Default Value
Output
Customize Default Value Format
Output
Enter start date:[Oct 20 2020] # user accepts default value datetime.date(2020, 10, 20)