Generic Menu Functions

Summary: Functions for menu display / user input, to be used by all menus in the system.

Description: This feature aims to standardize and simplify menu display & user input. All functions should be part of src/choc_an_simulator/user_io.py

Requirements:

  • Implement prompt_str(message: str, character_limit: range) -> str
    • Fields:
      • message: The message to display before requesting input
      • character_limit: A range object indicating the upper / lower character limit
    • returns: The user's input.
    • Notes:
      • Prompt should repeat until a valid entry is made.
  • Implement prompt_int(message: str, character_limit: range) -> int
    • Fields:
      • message: The message to display before requesting input
      • character_limit: A range object indicating the upper / lower character limit (or number of digits)
    • returns: The user's input.
    • Notes:
      • Prompt should repeat until a valid entry is made.
  • Implement prompt_menu_options(message: str, choices: List[str]) -> (int, str)
    • Fields:
      • message: The message to display before menu options
      • choices: A list of menu options
    • returns: The index and text of the selected option.
    • Notes:
      • Choices should be numbered starting at 1, and converted back to starting at 0 before returning
      • Users should only be allowed to enter numbers within the choice range.
      • Prompt should repeat until a valid entry is made.

Related Issues:

Edited by Vlad Chevdar