initial commit

This commit is contained in:
2025-12-20 14:52:47 -06:00
commit 71397f0b8a
8 changed files with 1033 additions and 0 deletions

70
main.py Normal file
View File

@@ -0,0 +1,70 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
# It is assumed that the following scripts exist in the same directory:
# - manage_clients.py
# - track_time.py
# - create_invoice.py
# These modules will be run as separate processes.
def run_script_from_file(script_name):
"""
Runs a Python script as a subprocess.
Args:
script_name (str): The name of the Python file to run.
"""
# Check if the file exists
if not os.path.exists(script_name):
print(f"Error: The script '{script_name}' was not found.")
print("Please ensure all required script files are in the same directory.")
return
try:
# Run the script using subprocess.run
# This will execute the script's top-level code (including any code in
# its 'if __name__ == "__main__":' block).
print(f"\n--- Running {script_name} ---")
subprocess.run(['python3', script_name], check=True)
print(f"--- {script_name} completed ---")
except subprocess.CalledProcessError as e:
print(f"An error occurred while trying to run '{script_name}': {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
def main_menu():
"""
Displays the main menu and handles user input to run different scripts.
"""
while True:
print("\n" + "="*40)
print(" TIME TRACKER MAIN MENU")
print("="*40)
print("1. Manage Clients")
print("2. Track Time")
print("3. Create Invoice")
print("4. Reports")
print("0. Exit") # Changed Exit option to 0
print("="*40)
choice = input("Enter your choice (1-3, or 0): ") # Updated prompt
if choice == '1':
run_script_from_file('manage_clients.py')
elif choice == '2':
run_script_from_file('track_time.py')
elif choice == '3':
run_script_from_file('create_invoice.py')
elif choice == '4':
run_script_from_file('reports.py')
elif choice == '0': # Updated logic for the new exit choice
print("Exiting the Time Tracker. Goodbye!")
break
else:
print("Invalid choice. Please enter a number between 1 and 3, or 0 to exit.")
if __name__ == "__main__":
main_menu()