Import a .cgc bundle into the current database. Loads a pre-indexed graph snapshot into your database. Use --clear to replace all existing data with the bundle contents. Examples: cgc bundle import numpy.cgc cgc bundle import my-project.cgc --clear --yes
(
bundle_file: str = typer.Argument(..., help="Path to the .cgc bundle file to import"),
clear: bool = typer.Option(False, "--clear", help="Clear existing graph data before importing"),
yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation when using --clear"),
context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
)
| 776 | |
| 777 | @bundle_app.command("import") |
| 778 | def bundle_import( |
| 779 | bundle_file: str = typer.Argument(..., help="Path to the .cgc bundle file to import"), |
| 780 | clear: bool = typer.Option(False, "--clear", help="Clear existing graph data before importing"), |
| 781 | yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation when using --clear"), |
| 782 | context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"), |
| 783 | ): |
| 784 | """ |
| 785 | Import a .cgc bundle into the current database. |
| 786 | |
| 787 | Loads a pre-indexed graph snapshot into your database. Use --clear to |
| 788 | replace all existing data with the bundle contents. |
| 789 | |
| 790 | Examples: |
| 791 | cgc bundle import numpy.cgc |
| 792 | cgc bundle import my-project.cgc --clear --yes |
| 793 | """ |
| 794 | _load_credentials() |
| 795 | from codegraphcontext.core.cgc_bundle import CGCBundle |
| 796 | |
| 797 | services = _initialize_services(context) |
| 798 | if not all(services[:3]): |
| 799 | raise typer.Exit(code=1) |
| 800 | db_manager, graph_builder, code_finder = services[:3] |
| 801 | |
| 802 | try: |
| 803 | bundle_path = Path(bundle_file) |
| 804 | |
| 805 | if not bundle_path.exists(): |
| 806 | console.print(f"[bold red]Bundle file not found: {bundle_path}[/bold red]") |
| 807 | raise typer.Exit(code=1) |
| 808 | |
| 809 | if not _confirm_bundle_clear(clear, yes): |
| 810 | return |
| 811 | |
| 812 | console.print(f"[cyan]Importing bundle from {bundle_path}...[/cyan]") |
| 813 | |
| 814 | bundle = CGCBundle(db_manager) |
| 815 | success, message = bundle.import_from_bundle( |
| 816 | bundle_path, |
| 817 | clear_existing=clear |
| 818 | ) |
| 819 | |
| 820 | if success: |
| 821 | console.print(f"[bold green]{message}[/bold green]") |
| 822 | else: |
| 823 | console.print(f"[bold red]Import failed: {message}[/bold red]") |
| 824 | raise typer.Exit(code=1) |
| 825 | |
| 826 | finally: |
| 827 | db_manager.close_driver() |
| 828 | |
| 829 | @bundle_app.command("load") |
| 830 | def bundle_load( |
no test coverage detected