56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# encoding: utf-8
|
|
# main.py - 程序入口,仅负责主循环与菜单分发
|
|
|
|
from rich.console import Console
|
|
from rich.prompt import Prompt
|
|
|
|
from handlers.change_handler import menu_change_requirements
|
|
from handlers.project_handler import (
|
|
menu_create_project,
|
|
menu_delete_project,
|
|
menu_list_projects,
|
|
menu_project_detail,
|
|
)
|
|
from ui.display import print_banner, print_main_menu
|
|
|
|
console = Console()
|
|
|
|
|
|
def main() -> None:
|
|
print_banner()
|
|
|
|
menu_handlers = {
|
|
"1": menu_create_project,
|
|
"2": menu_change_requirements,
|
|
"3": menu_list_projects,
|
|
"4": menu_project_detail,
|
|
"5": menu_delete_project,
|
|
}
|
|
|
|
while True:
|
|
print_main_menu()
|
|
choice = Prompt.ask(
|
|
"请输入选项",
|
|
choices=["0", "1", "2", "3", "4", "5"],
|
|
default="0",
|
|
)
|
|
|
|
if choice == "0":
|
|
console.print("\n[bold cyan]👋 再见![/bold cyan]\n")
|
|
break
|
|
|
|
handler = menu_handlers.get(choice)
|
|
if handler:
|
|
try:
|
|
handler()
|
|
except KeyboardInterrupt:
|
|
console.print("\n[yellow]操作已中断,返回主菜单。[/yellow]")
|
|
except Exception as e:
|
|
console.print(f"[bold red]❌ 发生错误:{e}[/bold red]")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |