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

Function bundle_export

src/codegraphcontext/cli/main.py:707–756  ·  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

705
706@bundle_app.command("export")
707def bundle_export(
708 output: str = typer.Argument(..., help="Output path for the .cgc bundle file"),
709 repo: Optional[str] = typer.Option(None, "--repo", "-r", help="Specific repository path to export (default: export all)"),
710 no_stats: bool = typer.Option(False, "--no-stats", help="Skip statistics generation"),
711 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
712):
713 """
714 Export the current graph to a portable .cgc bundle.
715
716 Creates a pre-indexed graph snapshot that can be distributed and loaded
717 instantly without re-indexing. Perfect for sharing famous repositories.
718
719 Examples:
720 cgc bundle export numpy.cgc --repo /path/to/numpy
721 cgc bundle export my-project.cgc
722 cgc bundle export all-repos.cgc --no-stats
723 """
724 _load_credentials()
725 from codegraphcontext.core.cgc_bundle import CGCBundle
726
727 services = _initialize_services(context)
728 if not all(services[:3]):
729 raise typer.Exit(code=1)
730 db_manager, _, code_finder = services[:3]
731
732 try:
733 output_path = Path(output)
734 repo_path = Path(repo).resolve() if repo else None
735
736 console.print(f"[cyan]Exporting graph to {output_path}...[/cyan]")
737 if repo_path:
738 console.print(f"[dim]Repository: {repo_path}[/dim]")
739 else:
740 console.print("[dim]Exporting all repositories[/dim]")
741
742 bundle = CGCBundle(db_manager)
743 success, message = bundle.export_to_bundle(
744 output_path,
745 repo_path=repo_path,
746 include_stats=not no_stats
747 )
748
749 if success:
750 console.print(f"[bold green]{message}[/bold green]")
751 else:
752 console.print(f"[bold red]Export failed: {message}[/bold red]")
753 raise typer.Exit(code=1)
754
755 finally:
756 db_manager.close_driver()
757
758def _confirm_bundle_clear(clear: bool, yes: bool) -> bool:
759 """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