MCPcopy Index your code
hub / github.com/HKUDS/DeepCode / main

Function main

cli/main_cli.py:244–333  ·  view source on GitHub ↗

主函数

()

Source from the content-addressed store, hash-verified

242
243
244async def main():
245 """主函数"""
246 # 解析命令行参数
247 args = parse_arguments()
248
249 # 显示横幅
250 print_enhanced_banner()
251
252 # 检查环境
253 if not check_environment():
254 print(
255 f"\n{Colors.FAIL}🚨 Environment check failed. Please fix the issues and try again.{Colors.ENDC}"
256 )
257 sys.exit(1)
258
259 try:
260 # 创建CLI应用
261 app = CLIApp()
262
263 # 设置配置 - 默认禁用索引功能以加快处理速度
264 if args.optimized:
265 app.cli.enable_indexing = False
266 print(
267 f"\n{Colors.YELLOW}⚡ Optimized mode enabled - indexing disabled{Colors.ENDC}"
268 )
269 else:
270 # 默认也禁用索引功能
271 app.cli.enable_indexing = False
272 print(
273 f"\n{Colors.YELLOW}⚡ Fast mode enabled - indexing disabled by default{Colors.ENDC}"
274 )
275
276 # Configure document segmentation settings
277 if hasattr(args, "disable_segmentation") and args.disable_segmentation:
278 print(
279 f"\n{Colors.MAGENTA}📄 Document segmentation disabled - using traditional processing{Colors.ENDC}"
280 )
281 app.cli.segmentation_enabled = False
282 app.cli.segmentation_threshold = args.segmentation_threshold
283 app.cli._save_segmentation_config()
284 else:
285 print(
286 f"\n{Colors.BLUE}📄 Smart document segmentation enabled (threshold: {args.segmentation_threshold} chars){Colors.ENDC}"
287 )
288 app.cli.segmentation_enabled = True
289 app.cli.segmentation_threshold = args.segmentation_threshold
290 app.cli._save_segmentation_config()
291
292 # 检查是否为直接处理模式
293 if args.file or args.url or args.chat or args.requirement:
294 if args.file:
295 # 验证文件存在
296 if not os.path.exists(args.file):
297 print(f"{Colors.FAIL}❌ File not found: {args.file}{Colors.ENDC}")
298 sys.exit(1)
299 # 使用 file:// 前缀保持与交互模式一致,确保文件被复制而非移动
300 file_url = f"file://{os.path.abspath(args.file)}"
301 success = await run_direct_processing(app, file_url, "file")

Callers 2

app.pyFile · 0.90
main_cli.pyFile · 0.70

Calls 8

CLIAppClass · 0.90
parse_argumentsFunction · 0.85
print_enhanced_bannerFunction · 0.85
check_environmentFunction · 0.85
run_direct_processingFunction · 0.85
run_requirement_analysisFunction · 0.85

Tested by

no test coverage detected