MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / bundle_export

Function bundle_export

src/codegraphcontext/cli/main.py:611–660  ·  view source on GitHub ↗

Export the current graph to a portable .cgc bundle. Creates a pre-indexed graph snapshot that can be distributed and loaded instantly without re-indexing. Perfect for sharing famous repositories. Examples: cgc bundle export numpy.cgc --repo /path/to/numpy c

(
    output: str = typer.Argument(..., help="Output path for the .cgc bundle file"),
    repo: Optional[str] = typer.Option(None, "--repo", "-r", help="Specific repository path to export (default: export all)"),
    no_stats: bool = typer.Option(False, "--no-stats", help="Skip statistics generation"),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
)

Source from the content-addressed store, hash-verified

609
610@bundle_app.command("export")
611def bundle_export(
612 output: str = typer.Argument(..., help="Output path for the .cgc bundle file"),
613 repo: Optional[str] = typer.Option(None, "--repo", "-r", help="Specific repository path to export (default: export all)"),
614 no_stats: bool = typer.Option(False, "--no-stats", help="Skip statistics generation"),
615 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
616):
617 """
618 Export the current graph to a portable .cgc bundle.
619
620 Creates a pre-indexed graph snapshot that can be distributed and loaded
621 instantly without re-indexing. Perfect for sharing famous repositories.
622
623 Examples:
624 cgc bundle export numpy.cgc --repo /path/to/numpy
625 cgc bundle export my-project.cgc
626 cgc bundle export all-repos.cgc --no-stats
627 """
628 _load_credentials()
629 from codegraphcontext.core.cgc_bundle import CGCBundle
630
631 services = _initialize_services(context)
632 if not all(services[:3]):
633 raise typer.Exit(code=1)
634 db_manager, _, code_finder = services[:3]
635
636 try:
637 output_path = Path(output)
638 repo_path = Path(repo).resolve() if repo else None
639
640 console.print(f"[cyan]Exporting graph to {output_path}...[/cyan]")
641 if repo_path:
642 console.print(f"[dim]Repository: {repo_path}[/dim]")
643 else:
644 console.print("[dim]Exporting all repositories[/dim]")
645
646 bundle = CGCBundle(db_manager)
647 success, message = bundle.export_to_bundle(
648 output_path,
649 repo_path=repo_path,
650 include_stats=not no_stats
651 )
652
653 if success:
654 console.print(f"[bold green]{message}[/bold green]")
655 else:
656 console.print(f"[bold red]Export failed: {message}[/bold red]")
657 raise typer.Exit(code=1)
658
659 finally:
660 db_manager.close_driver()
661
662def _confirm_bundle_clear(clear: bool, yes: bool) -> bool:
663 """Return True if import may proceed; False if user cancelled."""

Callers 1

export_shortcutFunction · 0.85

Calls 7

export_to_bundleMethod · 0.95
CGCBundleClass · 0.90
_load_credentialsFunction · 0.85
_initialize_servicesFunction · 0.85
printMethod · 0.80
resolveMethod · 0.45
close_driverMethod · 0.45

Tested by

no test coverage detected