Generic menu functions
Wrote Generic Menu Functions
Related Issue(s)
closes #8 (closed)
Changes Made
- added prompt_str(), prompt_int(), prompt_menu_options(), and prompt_date().
- I made a few changes compared to the issue description
- All prompt_{x} functions return None when the user presses Ctrl+C during input. This is so that users can always cancel entering information.
- This possibility will need to be considered when the functions are used, e.g by returning to a previous menu, exiting the application, etc.
- Added prompt_date(), since we'll need it eventually anyway. It has optional min_date & max_date arguments, so we can dis-allow future dates, set a date minimum, etc.
- Made char_limit optional - not all applications require a character limit.
- Added numeric_limit to prompt_int, since it felt like a good idea and was needed by prompt_menu_item
- Added examples for all of these functions in examples/prompting.py
- Added a little color-printing class, ~just for fun~. Right now it has functions for printing warning & failure colors, as well as a generic version.
- All prompt_{x} functions return None when the user presses Ctrl+C during input. This is so that users can always cancel entering information.
Test Plan
make test
Checklist
-
Code follows the project's coding style and conventions. -
Automated tests for the changes have been added or existing tests have been updated. -
Code coverage for new or modified code is maintained or improved. -
The code builds and runs without errors or warnings. -
Documentation has been updated to reflect the changes made. -
All discussions and feedback on the PR have been addressed. -
CI/CD pipelines pass successfully, including any required checks or tests. -
The PR has been reviewed and approved by the designated reviewers.
Additional Notes
Ok I'm actually going to stop writing code now, I swear.
Edited by Danny Love