主函数
()
| 464 | |
| 465 | |
| 466 | async def main(): |
| 467 | """主函数""" |
| 468 | start_time = time.time() |
| 469 | |
| 470 | try: |
| 471 | # 创建并运行CLI应用 |
| 472 | app = CLIApp() |
| 473 | await app.run_interactive_session() |
| 474 | |
| 475 | except KeyboardInterrupt: |
| 476 | print(f"\n{Colors.WARNING}⚠️ Application interrupted by user{Colors.ENDC}") |
| 477 | except Exception as e: |
| 478 | print(f"\n{Colors.FAIL}❌ Application error: {str(e)}{Colors.ENDC}") |
| 479 | finally: |
| 480 | end_time = time.time() |
| 481 | print( |
| 482 | f"\n{Colors.BOLD}{Colors.CYAN}⏱️ Total runtime: {end_time - start_time:.2f} seconds{Colors.ENDC}" |
| 483 | ) |
| 484 | |
| 485 | # 清理缓存文件 |
| 486 | print(f"{Colors.YELLOW}🧹 Cleaning up cache files...{Colors.ENDC}") |
| 487 | if os.name == "nt": # Windows |
| 488 | os.system( |
| 489 | "powershell -Command \"Get-ChildItem -Path . -Filter '__pycache__' -Recurse -Directory | Remove-Item -Recurse -Force\" 2>nul" |
| 490 | ) |
| 491 | else: # Unix/Linux/macOS |
| 492 | os.system('find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null') |
| 493 | |
| 494 | print( |
| 495 | f"{Colors.OKGREEN}✨ Goodbye! Thanks for using DeepCode CLI! ✨{Colors.ENDC}" |
| 496 | ) |
| 497 | |
| 498 | |
| 499 | if __name__ == "__main__": |
no test coverage detected