解析命令行参数
()
| 88 | |
| 89 | |
| 90 | def parse_arguments(): |
| 91 | """解析命令行参数""" |
| 92 | parser = argparse.ArgumentParser( |
| 93 | description="DeepCode CLI - Open-Source Code Agent by Data Intelligence Lab @ HKU", |
| 94 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 95 | epilog=f""" |
| 96 | {Colors.BOLD}Examples:{Colors.ENDC} |
| 97 | {Colors.CYAN}python main_cli.py{Colors.ENDC} # Interactive mode |
| 98 | {Colors.CYAN}python main_cli.py --file paper.pdf{Colors.ENDC} # Process file directly |
| 99 | {Colors.CYAN}python main_cli.py --url https://...{Colors.ENDC} # Process URL directly |
| 100 | {Colors.CYAN}python main_cli.py --chat "Build a web app..."{Colors.ENDC} # Process chat requirements |
| 101 | {Colors.CYAN}python main_cli.py --requirement "ML system for..."{Colors.ENDC} # Guided requirement analysis (NEW) |
| 102 | {Colors.CYAN}python main_cli.py --optimized{Colors.ENDC} # Use optimized mode |
| 103 | {Colors.CYAN}python main_cli.py --disable-segmentation{Colors.ENDC} # Disable document segmentation |
| 104 | {Colors.CYAN}python main_cli.py --segmentation-threshold 30000{Colors.ENDC} # Custom segmentation threshold |
| 105 | |
| 106 | {Colors.BOLD}Pipeline Modes:{Colors.ENDC} |
| 107 | {Colors.GREEN}Comprehensive{Colors.ENDC}: Full intelligence analysis with indexing |
| 108 | {Colors.YELLOW}Optimized{Colors.ENDC}: Fast processing without indexing |
| 109 | {Colors.BLUE}Requirement Analysis{Colors.ENDC}: Guided Q&A to refine requirements (NEW) |
| 110 | |
| 111 | {Colors.BOLD}Document Processing:{Colors.ENDC} |
| 112 | {Colors.BLUE}Smart Segmentation{Colors.ENDC}: Intelligent document segmentation for large papers |
| 113 | {Colors.MAGENTA}Supported Formats{Colors.ENDC}: PDF, DOCX, DOC, PPT, PPTX, XLS, XLSX, HTML, TXT, MD |
| 114 | """, |
| 115 | ) |
| 116 | |
| 117 | parser.add_argument( |
| 118 | "--file", "-f", type=str, help="Process a specific file (PDF, DOCX, TXT, etc.)" |
| 119 | ) |
| 120 | |
| 121 | parser.add_argument( |
| 122 | "--url", "-u", type=str, help="Process a research paper from URL" |
| 123 | ) |
| 124 | |
| 125 | parser.add_argument( |
| 126 | "--chat", |
| 127 | "-t", |
| 128 | type=str, |
| 129 | help="Process coding requirements via chat input (provide requirements as argument)", |
| 130 | ) |
| 131 | |
| 132 | parser.add_argument( |
| 133 | "--requirement", |
| 134 | "-r", |
| 135 | type=str, |
| 136 | help="Process requirements via guided analysis (provide initial idea as argument)", |
| 137 | ) |
| 138 | |
| 139 | parser.add_argument( |
| 140 | "--optimized", |
| 141 | "-o", |
| 142 | action="store_true", |
| 143 | help="Use optimized mode (skip indexing for faster processing)", |
| 144 | ) |
| 145 | |
| 146 | parser.add_argument( |
| 147 | "--disable-segmentation", |