53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
import os
|
|
from colorama import Fore, Style
|
|
|
|
from Modules.global_commands import *
|
|
from Modules.search_for_word import search_for_word_in_directory, create_search_submenu
|
|
from Modules.common_ui import *
|
|
|
|
|
|
|
|
def display_menu(menu_options):
|
|
while True:
|
|
header(is_main_menu=True) # Show full details on main menu
|
|
for key, value in menu_options.items():
|
|
print(f"[{key}] {value['name'].upper()}")
|
|
print("[0] Logout")
|
|
print("[NOTE] Analyst Notebook | [ABOUT] About Page")
|
|
print("[SEARCH] Search for a Term\n") # Add a global search option
|
|
|
|
choice = input("Enter your choice: ").strip().lower()
|
|
|
|
# Handle global commands
|
|
if choice in ["note", "about"]:
|
|
global_command_handler(choice) # Call the global command handler
|
|
continue # Restart the loop after handling global commands
|
|
|
|
# Handle search
|
|
if choice == "search":
|
|
term = input("Enter the term to search for: ").strip()
|
|
search_results = search_for_word_in_directory(".", term) # Search in the current directory
|
|
if search_results:
|
|
print(f"\n{Fore.GREEN}Search Results for '{term}':{Style.RESET_ALL}")
|
|
create_search_submenu(search_results) # Open dynamic submenu for results
|
|
else:
|
|
print(f"{Fore.RED}No results found for '{term}'.{Style.RESET_ALL}")
|
|
input("Press Enter to continue...")
|
|
continue
|
|
|
|
# Match the choice to a menu option
|
|
if choice in menu_options:
|
|
menu_options[choice]["submenu"]() # Call the submenu without arguments
|
|
elif choice in ["0", "q", "exit", "quit"]:
|
|
print("Logging out...")
|
|
break
|
|
else:
|
|
print("Invalid choice. Please try again.")
|
|
|
|
def print_info(title, content):
|
|
header()
|
|
print("=" * 40)
|
|
print(f"{title.center(40)}")
|
|
print("=" * 40)
|
|
print(content)
|
|
input("\nPress Enter to return to the menu...") |