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

Function delete

src/codegraphcontext/cli/main.py:1559–1676  ·  view source on GitHub ↗

Deletes a repository from the code graph. Use --all to delete all repositories at once (requires confirmation). Examples: cgc delete ./my-project # Delete specific repository cgc delete --all # Delete all repositories

(
    path: Optional[str] = typer.Argument(None, help="Path of the repository to delete from the code graph."),
    all_repos: bool = typer.Option(False, "--all", help="Delete all indexed repositories"),
    yes: bool = typer.Option(False, "--yes", "-y", help="Skip the confirmation prompt (for CI/non-interactive use)"),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use")
)

Source from the content-addressed store, hash-verified

1557
1558@app.command()
1559def delete(
1560 path: Optional[str] = typer.Argument(None, help="Path of the repository to delete from the code graph."),
1561 all_repos: bool = typer.Option(False, "--all", help="Delete all indexed repositories"),
1562 yes: bool = typer.Option(False, "--yes", "-y", help="Skip the confirmation prompt (for CI/non-interactive use)"),
1563 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use")
1564):
1565 """
1566 Deletes a repository from the code graph.
1567
1568 Use --all to delete all repositories at once (requires confirmation).
1569
1570 Examples:
1571 cgc delete ./my-project # Delete specific repository
1572 cgc delete --all # Delete all repositories
1573 """
1574 _load_credentials()
1575
1576 if all_repos:
1577 if not config_manager.is_db_deletion_allowed():
1578 console.print(
1579 "[bold red]Error:[/bold red] Full database deletion is disabled. "
1580 "Set ALLOW_DB_DELETION=true in config to enable."
1581 )
1582 raise typer.Exit(code=1)
1583
1584 # Delete all repositories
1585 services = _initialize_services(context)
1586 if not all(services[:3]):
1587 raise typer.Exit(code=1)
1588 db_manager, graph_builder, code_finder = services[:3]
1589
1590 try:
1591 # Get list of repositories
1592 repos = code_finder.list_indexed_repositories()
1593
1594 if not repos:
1595 console.print("[yellow]No repositories to delete.[/yellow]")
1596 return
1597
1598 # Show what will be deleted
1599 console.print(f"\n[bold red]⚠️ WARNING: You are about to delete ALL {len(repos)} repositories![/bold red]\n")
1600
1601 table = Table(show_header=True, header_style="bold magenta")
1602 table.add_column("Name", style="cyan")
1603 table.add_column("Path", style="dim")
1604
1605 for repo in repos:
1606 table.add_row(repo.get("name", ""), repo.get("path", ""))
1607
1608 console.print(table)
1609 console.print()
1610
1611 # Double confirmation
1612 if not typer.confirm("Are you sure you want to delete ALL repositories?", default=False):
1613 console.print("[yellow]Deletion cancelled.[/yellow]")
1614 return
1615
1616 console.print("[yellow]Please type 'delete all' to confirm:[/yellow] ", end="")

Callers 3

delete_abbrevFunction · 0.85
MapOperationsFunction · 0.85
DeleteMethod · 0.85

Calls 11

_load_credentialsFunction · 0.85
_initialize_servicesFunction · 0.85
delete_helperFunction · 0.85
printMethod · 0.80
add_columnMethod · 0.80
add_rowMethod · 0.80
getMethod · 0.65
close_driverMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected