{"id":16972201,"url":"https://github.com/jmcaluyafuentes/terminal-app","last_synced_at":"2026-05-01T12:32:32.607Z","repository":{"id":237923729,"uuid":"795498530","full_name":"jmcaluyafuentes/terminal-app","owner":"jmcaluyafuentes","description":"Term 1 Final Assignment (Coder Academy, Diploma of IT)","archived":false,"fork":false,"pushed_at":"2024-06-19T06:45:30.000Z","size":3059,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-22T08:50:33.919Z","etag":null,"topics":["algorithm","bash-script","control-flow","docstrings","dry-principle","error-handling","functions","libraries","loops","packages","pep8","project-management","python","source-control","tdd","variables"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmcaluyafuentes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-03T12:15:48.000Z","updated_at":"2024-09-07T13:34:11.000Z","dependencies_parsed_at":"2024-06-19T14:17:51.149Z","dependency_job_id":"74ce2c4f-e91b-40fb-9525-c4d50282451e","html_url":"https://github.com/jmcaluyafuentes/terminal-app","commit_stats":null,"previous_names":["jmcaluyafuentes/terminal-app-t1a3","jmcaluyafuentes/terminal-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jmcaluyafuentes/terminal-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcaluyafuentes%2Fterminal-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcaluyafuentes%2Fterminal-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcaluyafuentes%2Fterminal-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcaluyafuentes%2Fterminal-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmcaluyafuentes","download_url":"https://codeload.github.com/jmcaluyafuentes/terminal-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcaluyafuentes%2Fterminal-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32497812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","bash-script","control-flow","docstrings","dry-principle","error-handling","functions","libraries","loops","packages","pep8","project-management","python","source-control","tdd","variables"],"created_at":"2024-10-14T00:58:01.832Z","updated_at":"2026-05-01T12:32:32.551Z","avatar_url":"https://github.com/jmcaluyafuentes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terminal Application\n\n## Term 1, Assignment 3\n\nDiploma of IT - Web Development  \nCoder Academy\n\n## Purpose\n\nWelcome to my Python project developed to showcase my knowledge and skills on Python Programming at Coder Academy. This is part of Term 1 assignment by developing terminal application.\n\n## About the Application\n\nThe name of my app is \"Pregnancy Tracker\".\n\nThis application was inspired by my wife's pregnancy journey, as she was 9 weeks pregnant when I initially submitted the idea for approval. \n\nThe purpose of this app is to provide helpful information related to pregnancy such as calculating the gestational age, estimate due date, countdown until due date and many more. Please refer to the Features section below for details.\n\n## Github Repository\n\nYou can find the Github repository for my terminal app in [https://github.com/jmcaluyafuentes/terminal-app-T1A3](https://github.com/jmcaluyafuentes/terminal-app-T1A3).\n\n## Preview of the application\n\nUpon running the app, the console displays something like the below image as a preview of the application.\n\n![Preview of the Pregnancy Tracker app](./markdown-images/app-screenshot-1.png)\n\n## Development Plan\n\nYou can find the Trello board for my terminal app in [https://trello.com/b/qk7qA75c/t1a3-terminal-app](https://trello.com/b/qk7qA75c/t1a3-terminal-app).\n\nBelow is a snapshot of my Trello board during the initial stage of my terminal app development:\n\n![Trello board at early stage](./markdown-images/trello-1-early-stage.png)\n\nBelow is a snapshot of the final stage:\n\n![Trello board at early stage](./markdown-images/trello-2-final-stage.png)\n\nThe Trello board tool is very useful in organizing tasks, tracking progress, and managing the development process of my terminal app.\n\n## Technology Stack\n\n* Languages: Python 3 for the application logic and bash script for system-level interactions.  \n* Project Type: Terminal application designed to run in a command-line interface (CLI).  \n* IDE: Visual Studio Code (VS Code) used for writing code and debugging.  \n* Version Control: Git for version and source control.  \n* Repository Hosting: GitHub for hosting the Git repository remotely.  \n* Package Manager: pip for managing Python packages and dependencies.  \n* Operating System Compatibility: Developed for Microsoft Windows operating systems, utilizing the Windows Subsystem for Linux (WSL) for Linux compatibility.\n\n## Code Styling Guide\n\n* PEP8 Styling - guide and styling convention for writing code  \n* PEP257 Styling - guide and styling convention for writing docstring\n\n## Dependencies required by the application\n\n#### Standard Library Modules\n\n* sys: Provides access to system-specific parameters and functions.  \n* textwrap: Offers convenient text wrapping and filling functionality.  \n* datetime: Supports date and time manipulation and formatting.  \n* csv: Facilitates reading and writing CSV (Comma-Separated Values)   files.\n\n#### Third-Party Packages\n\n* Colorama (version 0.4.6): Provides cross-platform colored terminal text.  \n* Emoji (version 2.11.1): Allows easy usage of emoji characters in Python.  \n* Pytest (version 8.2.0): A testing framework for Python projects.  \n\n#### Pytest Dependencies (installed automatically with pytest)\n\n* exceptiongroup (version 1.2.1)  \n* iniconfig (version 2.0.0)  \n* packaging (version 24.0)  \n* pluggy (version 1.5.0)  \n* tomli (version 2.0.1)  \n\n## System and hardware requirements\n\n### Prerequisites\n\n* Make sure you have the latest version of Windows 10 or later.\n* Enable the Windows Subsystem for Linux (WSL) on your Windows system.\n\n#### Step 1: Install Windows 10\n\nInstall Windows 10 into your laptop or desktop. Check the latest version here https://learn.microsoft.com/en-us/windows/release-health/.\n\n#### Step 2: Install Windows Terminal\n\nInstall Windows Terminal from Microsoft Store here https://apps.microsoft.com/detail/9n0dx20hk701?rtc=1\u0026hl=en-au\u0026gl=AU.\n\n#### Step 3. Install Ubuntu 22.04 WSL\n\n\"Windows Subsystem For Linux (WSL) is a technology built into Windows that allows running a Linux operating system within it's own environment or container, side-by-side with Windows. This gives us the best of both worlds. (source: Coder Academy)\"\n\n1. Go to https://learn.microsoft.com/en-us/windows/wsl/install.\n\n    Pre-requisite: You must be running Windows 10 version 2004 and higher.\n\n2. Install WSL command\n\n    \"Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting \"Run as administrator\", enter the wsl --install command, then restart your machine. (source: Microsoft)\"\n\n    In Powershell:\n\n    ```\n    wsl --install\n    ```\n\n3. Check the version of your Ubuntu\n\n    ```\n    lsb_release -rs\n    ```\n\n### Check your Python version\n\nGuide is available here https://learn.microsoft.com/en-us/windows/python/web-frameworks#install-python-pip-and-venv.\n\n\"Ubuntu 18.04 LTS comes with Python 3.6 already installed, but it does not come with some of the modules that you may expect to get with other Python installations. We will still need to install pip, the standard package manager for Python, and venv, the standard module used to create and manage lightweight virtual environments. (source: Microsoft)\"\n\n#### Step 1. Open your Ubuntu terminal\n\nSearch 'Ubuntu' and click to open the terminal.\n\n#### Step 2. You must have a Python3 version\n\n1. Confirm if you already have Python3 by typing the command below and hit enter.\n\n    ```\n    python3 --version\n    ```\n\n    This should return your Python version number such as 3.12.10\n\n2. Update your version in Python\n\n    If you need to update your version of Python, first update your Ubuntu version by entering:\n\n    ```\n    sudo apt update \u0026\u0026 sudo apt upgrade\n    ```\n\n    Then update Python using:\n\n    ```\n    sudo apt upgrade python3\n    ```\n\n#### Step 3. Install pip\n\n1. Enter the command below.\n\n    ```\n    sudo apt install python3-pip\n    ```\n\n2. Pip allows you to install and manage additional packages that are not part of the Python standard library.\n\n## How to Install the Application\n\n#### Step 1. Open the directory in your laptop or desktop\n\n1. Open your Ubuntu terminal\n\n2. Check your current directory\n\n    ```\n    pwd\n    ```\n\n3. Navigate to the directory where you want to install the Pregnancy Tracker app.\n\n    ```\n    cd ./path-to-your-folder\n    ```\n\n    Replace the 'path-to-your-folder' with the actual path of your directory.\n\n#### Step 2. Clone my repository\n\n1. Copy and paste below command into your terminal\n\n    ```\n    git clone git@github.com:jmcaluyafuentes/terminal-app-T1A3.git\n    ```\n\n#### Step 3. Run the Pregnancy Tracker app\n\n1. Navigate to the project directory\n\n    ```\n    cd terminal-app-T1A3\n    ```\n\n2. Change the permission of the script file run_app.sh\n\n    ```\n    chmod +x run_app.sh \n    ```\n\n3. Run the application by typing this command\n\n    ```\n    ./run_app.sh\n    ```\n\n    * This command will automatically install a virtual environment into your selected directory so that all packages in this app will not be installed to the global environment.\n\n    * The command also automatically installs all dependencies (i.e., third-party packages) necessary to run the app as intended.\n\n    * Lastly, the command will run the application.\n\n#### Step 4. How to exit the app\n\n1. To exit the app at anytime, type \"QUIT\" (case-insensitive) and press enter.  \n\n2. Alternatively, you can use the 'CTRL + C' in your keyboard.\n\n## Features of the Application\n\n### 1. Pregnancy Information\n\nInput: Date of last menstrual period entered by the user\n\nOutputs:\n\na. Number of Weeks Pregnant: Calculates and displays the number of weeks pregnant based on the input date.\n\nb. Trimester Information: Indicates whether the user is in her 1st, 2nd, or 3rd trimester of pregnancy.\n\nc. Estimated Due Date: Provides an estimated due date based on the input date.\n\nd. Countdown: Displays a countdown (in weeks and days) from current date to the estimated due date.\n\n#### Run the app by entering the command \"./run_app.sh\" in the terminal. \n\nPlease take note that every time you enter a command, hit enter so that the app can execute the command.\n\n![Preview of the Pregnancy Tracker app](./markdown-images/app-screenshot-1.png)\n\nSelect 1 for Pregnancy Information:\n\n![app snapshot](./markdown-images/feature1-1.png)\n\nEnter the date of last menstrual period:\n\n![app snapshot](./markdown-images/feature1-2.png)\n\nThen the app will display the pregnancy information:\n\n![app snapshot](./markdown-images/feature1-3.png)\n\nSelect 2 to go back to main menu.\n\n### 2. Safety Information\n\nIn the early stage of development, this feature was previously named 'Precaution'.\n\nHowever, I realized that the appropriate title is \"Safety Information\" because it encompasses a broader scope of ensuring the well-being and health safety of the pregnant user.\n\nFrom the main menu, select 2 for Safety Information:\n\n![app snapshot](./markdown-images/feature2-1.png)\n\n### Sub-features:\n\n#### 2.1 Food Safety Information\n\nInput: Specific food item (e.g., Grapes) entered by the user\n\nOutput:\n\nDetermines whether the food is \"Safe to Eat\", \"Not Safe to Eat\" or other information relevant to food safety.\n\nSelect 1 for Food Safety:\n\n![app snapshot](./markdown-images/feature2-2.png)\n\nEnter the food:\n\n![app snapshot](./markdown-images/feature2-3.png)\n\nThe app will display the food safety information:\n\n![app snapshot](./markdown-images/feature2-4.png)\n\nSelect 2 to go back to Safety Information menu.\n\n#### 2.2 Travel Safety Information\n\nInput: Planned travel date and last menstrual period date entered by the user.\n\nOutputs:\n\na. Estimated Weeks Pregnant on Travel Date: Calculates and displays the estimated number of weeks pregnant on the planned travel date.\n\nb. Safety Advice: Provides tailored advice related to the planned travel, such as:\nWhether it's safe to travel internationally.\nRecommendations such as obtaining a medical certificate or precautions at airport security.\nActivity Safety\nThis feature ensures that the user is aware of safe and appropriate activities during pregnancy.\n\nSelect 2 for the Travel Safety:\n\n![app snapshot](./markdown-images/feature2-6.png)\n\nEnter the last date of menstrual period:\n\n![app snapshot](./markdown-images/feature2-7.png)\n\nEnter the planned travel date:\n\n![app snapshot](./markdown-images/feature2-8.png)\n\nSelect from the given questions related to travel safety:\n\n![app snapshot](./markdown-images/feature2-9.png)\n\nThe app will display the travel safety information related to the question you selected:\n\n![app snapshot](./markdown-images/feature2-10.png)\n\nSelect 2 to go back to Safety Information menu.\n\n#### 3. Note-taking\n\nInput: User-generated personal notes (e.g., milestone events, feelings).\n\nOutputs:\n\na. Recording Notes: Notes are saved to a file, including the current date and time of entry.\n\nb. Confirmation Message: The app confirms successful addition of the note to the file.\n\nc. Viewing Recorded Notes: Users can view all past notes, providing a log of their pregnancy journey.\n\nSelect 3 for the note-taking:\n\n![app snapshot](./markdown-images/feature3-1.png)\n\nSelect 1 to write your personal notes:\n\n![app snapshot](./markdown-images/feature3-2.png)\n\nNow, write your notes:\n\n![app snapshot](./markdown-images/feature3-3.png)\n\nThe app will confirm the note was successfully recorded:\n\n![app snapshot](./markdown-images/feature3-4.png)\n\nSelect 2 to go back to one menu up.\n\nThen, select 2 to read your recorded note:\n\n![app snapshot](./markdown-images/feature3-5.png)\n\nThe app will display your recorded notes.\n\n![app snapshot](./markdown-images/feature3-6.png)\n\n#### Guide to display the detailed instructions or exit the app\n\n1. You can enter \"INSTRUCTIONS\" (case-insensitive) at any time in order to display the instructions. Enter \"CLOSE\" (case-insensitive) to close the instruction page.\n\n![app snapshot](./markdown-images/instructions-1.png)\n\nThe app will then display the instructions.\n\n![app snapshot](./markdown-images/instructions-2.png)\n\n2. You can enter \"QUIT\" (case-insensitive) at any time to exit the app.\n\n## Error Handling\n\n### Invalid selection entered\n\nIf invalid selection number is entered, the app will display an error.\n\n![app snapshot](./markdown-images/error-handling-1.png)\n\n### Invalid date or format\n\nIf invalid date or format is entered, the app will display an error.\n\n![app snapshot](./markdown-images/error-handling-2.png)\n\n### Last menstrual period date is greater than the current date (this is invalid)\n\nIf the last menstrual period date is greater than the current date, the app will display an error.\n\n![app snapshot](./markdown-images/error-handling-3.png)\n\n### Travel date is less than the current date (this is invalid)\n\nIf travel date is less than the current date, the app will display an error.\n\n![app snapshot](./markdown-images/error-handling-4.png)\n\n### Safety information of food entered is not available\n\nIf safety information of food entered is not available, the app will display an error.\n\n![app snapshot](./markdown-images/error-handling-5.png)\n\n### No file found\n\nIf there is no file found if the user selected to read her notes, the app will display an error. This happens if the user did not write any notes yet while trying to read the file.\n\n![app snapshot](./markdown-images/no-file-found.png)\n\n### Unit Testing\n\nThe date entered by the user is tested if valid using the pytest package.\n\n![app snapshot](./markdown-images/unit-test.png)\n\n## Logic of functions\n\n### Main function\n\n```py\nwhile True:\n            # Give user options based on the features of this app\n            print(dedent('''\n            Select from the following features.\\n\n            1. Pregnancy Information\n            2. Safety Information\n            3. Take Down Notes\n            '''))\n\n            # Prompt the user of her choice\n            user_choice = input('Enter your choice (1, 2 or 3): ')\n\n            # Check if user want to view the instructions or exits the app\n            instructions = guide_user_response(user_choice)\n\n            while not instructions:\n                # Check what option the user selected\n                if user_choice == '1':\n                    # Display pregnancy information based on user input\n                    pregnancy_information()\n                    display_guide_on_top() # From print_guide module\n                elif user_choice == '2':\n                    # Display safety information based on user input\n                    safety_info()\n                    display_guide_on_top() # From print_guide module\n                elif user_choice == '3':\n                    # Record user's personal notes\n                    note_taking()\n                    display_guide_on_top() # From print_guide module\n                else:\n                    # Display the guide for instructions and for quitting the app\n                    display_guide_on_top() # From print_guide module\n\n                    # Inform the user if she entered invalid choice\n                    print(Fore.RED + emoji.emojize(f':cross_mark: ERROR: \"{user_choice}\" is an invalid choice. Please enter 1, 2 or 3.') + Style.RESET_ALL)\n                instructions = True\n    # Exit the app if there are keyboard interrupt done by the user such 'Ctrl + C'\n    except KeyboardInterrupt:\n        print('\\n' * 200)\n        print(Fore.RED + emoji.emojize('\\n:cross_mark: ERROR: Keyboard interrupt received.\\n') + Style.RESET_ALL)\n        print(Fore.GREEN + 'Thank you for using the Pregnancy Tracker app. Goodbye!\\n' + Style.RESET_ALL)\n        sys.exit(1)\n```\n\n### Explanation:\n\n#### Outer while True Loop:\n\nThis loop runs indefinitely until explicitly terminated by a keyboard interrupt (Ctrl + C).\n\n#### User Interface:\n\nThe program displays a menu of features for the user to choose from.  \nIt prompts the user to enter their choice (1, 2, or 3) via the input function.\n\n#### Processing User Input:\n\nThe program calls the guide_user_response function to check if the user wants to view instructions or exit the app.\n\n#### Inner while not instructions Loop:\n\nThis loop executes as long as the instructions flag is False, indicating normal feature selection.\n\n#### Feature Handling:\n\nDepending on the user's choice (1, 2, or 3), the program executes different functions:\n\nIf user_choice is '1', it displays pregnancy information after calling the pregnancy_information() function.\n\nIf user_choice is '2', it displays safety information after calling the safety_info() function.\n\nIf user_choice is '3', it allows the user to take personal notes by calling the note_taking() function.\n\n#### Error Handling:\n\nIf the user enters an invalid choice (i.e., not '1', '2', or '3'), it displays an error message.\n\nThe program then exits the inner loop by setting instructions to True.\n\n#### Keyboard Interrupt Handling:\n\nThe program handles a KeyboardInterrupt exception (Ctrl + C) by displaying an error message and exiting gracefully.\n\n#### pregnancy_information function\n\n```py\ndef pregnancy_information() -\u003e None:\n    \"\"\"\n    Calculate and display the information about pregnancy such as gestational age \n    in weeks, trimester, estimated due date (EDD) and countdown until EDD.\n    \"\"\"\n    while True:\n        # Prompt the user to enter the date of her last menstrual period\n        last_period_date = get_last_period_date()\n\n        # Calculate gestational age in weeks\n        gestational_age, trimester, due_date, weeks_remaining, days_remaining = calc_pregnancy_info(last_period_date)\n\n        # Display the guide for instructions and for quitting the app\n        display_guide_on_top() # From print_guide module\n\n        # Display relevant information about the pregnancy\n        print(Fore.YELLOW + emoji.emojize(dedent(f'''\n            Pregnancy Information:\\n\n            You are {gestational_age} weeks pregnant :baby: \\n\n            Trimester: {trimester}\n            Estimated Due Date: {due_date.strftime('%d/%m/%Y')}\n            Due Date Countdown: {weeks_remaining} week(s) and {days_remaining} days.\n            ''') + Style.RESET_ALL))\n\n        # Prompt user what she wants to do next\n        if not get_user_next_action(): # From user_next_action module\n\n            # Display the guide for instructions and for quitting the app\n            display_guide_on_top() # From print_guide module\n            break # Return to main menu based on user choice\n```\n\n### Explanation:\n\n#### User Input for Last Menstrual Period:\n\nThe function starts by calling get_last_period_date() to prompt the user to enter the date of her last menstrual period and obtain the last_period_date as a datetime.date object.\n\n#### Calculating Pregnancy Information:\n\nIt then calls calc_pregnancy_info function to compute essential pregnancy information based on the last_period_date. This function calculates:\n\n* gestational_age: The number of weeks since the last menstrual period.\n* trimester: Determines whether the pregnancy is in the first, second, or third trimester based on gestational_age.\n* due_date: Estimated due date (EDD) based on the last_period_date.\n* weeks_remaining and days_remaining: Countdown until the estimated due date (due_date).\n\n#### Displaying Pregnancy Information:\n\nThe function then displays the calculated pregnancy information using formatted text and emojis, including:\n\n* gestational_age in weeks.\n* trimester.\n* due_date in DD/MM/YYYY format.\n* Countdown (weeks_remaining and days_remaining) until the estimated due date.\n\n#### Handling User Interaction:\n\nAfter displaying the pregnancy information, it prompts the user for the next action using get_user_next_action().\n\nIf the user chooses to return to the main menu (by not taking any further action), the function breaks out of the loop and returns control to the main menu.\n\n### get_last_period_date function\n\n```py\ndef get_last_period_date() -\u003e date:\n    \"\"\"\n    Prompt user to enter the last menstrual period date and parse the input for validation.\n\n    Returns:\n        date: The parsed date object representing the last menstrual period date.\n\n    \"\"\"\n    # Display the guide for instructions and for quitting the app\n    display_guide_on_top() # From print_guide module\n\n    while True:\n        # Prompt user to enter the date of her last menstrual period\n        user_input = input('\\nEnter the date of your last menstrual period (DD/MM/YYYY): ')\n        # Check if user want to view the instructions or exits the app\n        instructions = guide_user_response(user_input)\n\n        while not instructions:\n            try:\n                # Convert user input string into datetime.date object in DD/MM/YYYY format\n                last_period_date = datetime.strptime(user_input, '%d/%m/%Y').date()\n                # Get current date\n                current_date = date.today()\n                # Check if last_period_date is before the current date\n                if last_period_date \u003c current_date:\n                    return last_period_date\n                else:\n                    # Display the guide for instructions and for quitting the app\n                    display_guide_on_top() # From print_guide module\n                    # Display error message for invalid input date\n                    print(Fore.RED + emoji.emojize(dedent(f'''\n                    :cross_mark: ERROR: The last menstrual period date {last_period_date} must be before the current date.\n                    ''')) + Style.RESET_ALL)\n                    instructions = True\n            except ValueError:\n                # Display the guide for instructions and for quitting the app\n                display_guide_on_top() # From print_guide module\n                # Handles error gracefully if user entered invalid date format\n                print(Fore.RED + emoji.emojize(dedent(f'''\n                :cross_mark: ERROR: \"{user_input}\" is an invalid format.\n                Please enter the date in DD/MM/YYYY.'''\n                )) + Style.RESET_ALL)\n                instructions = True\n```\n\n### Explanation:\n\n#### User Input Prompt:\n\nThe function starts by displaying a guide for the user and prompts them to enter the date of their last menstrual period (DD/MM/YYYY format) using the input() function.\n\n#### Input Validation Loop:\n\nThe function enters a loop (while True) to continuously prompt the user for input until a valid date is provided.\n\n#### Date Parsing and Validation:\n\nInside the loop, it attempts to convert the user's input string into a datetime.date object using datetime.strptime().\n\nIf the conversion succeeds (try block), it checks if the parsed last_period_date is before the current date (date.today()). If valid, it returns the parsed date.\n\nIf the input format is invalid or cannot be parsed (except ValueError block), it displays an error message and continues to prompt the user for a valid input.\n\n#### Handling User Instructions:\n\nThe instructions flag controls whether to continue prompting the user (while not instructions) or allow the user to exit or view instructions based on their input.\n\n#### Error Handling and Messaging:\n\nIf there's an error parsing the date or the date is invalid, appropriate error messages are displayed using colored text.\n\n## References\n\nThe Royal Women's Hospital, Victoria Australia. \"Food Safety During Pregnancy.\" Available at: https://thewomens.r.worldssl.net/images/uploads/fact-sheets/Food-safety-during-pregnancy.pdf\n\nThe Alphabetizer. \"List of fruits and vegetables.\" Available at: https://alphabetizer.flap.tv/lists/list-of-fruits-and-vegetables.php\n\nBetter Health Channel. \"Pregnancy and travel.\" Available at: https://www.betterhealth.vic.gov.au/health/healthyliving/pregnancy-and-travel\n\nGreater Than. \"10 Fun Activities for Pregnant Moms for All Stages of Your Pregnancy.\" Available at: https://drinkgt.com/blogs/news/activities-for-pregnant-moms\n\nDavid Anson. Markdown lint MD007 - Unordered list indentation. Available at: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md007.md\n\nColorama (version 0.4.6) package in 'pypi.org'. Available at: https://pypi.org/project/colorama/\n\nEmoji (version 2.11.1) package in 'pypi.org'. Available at: https://pypi.org/project/emoji/\n\nPytest (version 8.2.0) package in 'pypi.org'. Available at: https://pypi.org/project/pytest/\n\nMicrosoft Website. How to install Linux on Windows with WSL. Available at: https://learn.microsoft.com/en-us/windows/wsl/install\n\nMicrosoft website. Get started using Python for web development on Windows. Available at: https://learn.microsoft.com/en-us/windows/python/web-frameworks#install-python-pip-and-venv\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcaluyafuentes%2Fterminal-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmcaluyafuentes%2Fterminal-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcaluyafuentes%2Fterminal-app/lists"}