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

Function delete

src/codegraphcontext/cli/main.py:1411–1511  ·  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"),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use")
)

Source from the content-addressed store, hash-verified

1409
1410@app.command()
1411def delete(
1412 path: Optional[str] = typer.Argument(None, help="Path of the repository to delete from the code graph."),
1413 all_repos: bool = typer.Option(False, "--all", help="Delete all indexed repositories"),
1414 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use")
1415):
1416 """
1417 Deletes a repository from the code graph.
1418
1419 Use --all to delete all repositories at once (requires confirmation).
1420
1421 Examples:
1422 cgc delete ./my-project # Delete specific repository
1423 cgc delete --all # Delete all repositories
1424 """
1425 _load_credentials()
1426
1427 if all_repos:
1428 if not config_manager.is_db_deletion_allowed():
1429 console.print(
1430 "[bold red]Error:[/bold red] Full database deletion is disabled. "
1431 "Set ALLOW_DB_DELETION=true in config to enable."
1432 )
1433 raise typer.Exit(code=1)
1434
1435 # Delete all repositories
1436 services = _initialize_services(context)
1437 if not all(services[:3]):
1438 raise typer.Exit(code=1)
1439 db_manager, graph_builder, code_finder = services[:3]
1440
1441 try:
1442 # Get list of repositories
1443 repos = code_finder.list_indexed_repositories()
1444
1445 if not repos:
1446 console.print("[yellow]No repositories to delete.[/yellow]")
1447 return
1448
1449 # Show what will be deleted
1450 console.print(f"\n[bold red]⚠️ WARNING: You are about to delete ALL {len(repos)} repositories![/bold red]\n")
1451
1452 table = Table(show_header=True, header_style="bold magenta")
1453 table.add_column("Name", style="cyan")
1454 table.add_column("Path", style="dim")
1455
1456 for repo in repos:
1457 table.add_row(repo.get("name", ""), repo.get("path", ""))
1458
1459 console.print(table)
1460 console.print()
1461
1462 # Double confirmation
1463 if not typer.confirm("Are you sure you want to delete ALL repositories?", default=False):
1464 console.print("[yellow]Deletion cancelled.[/yellow]")
1465 return
1466
1467 console.print("[yellow]Please type 'delete all' to confirm:[/yellow] ", end="")
1468 confirmation = input()

Callers 3

delete_abbrevFunction · 0.85
MapOperationsFunction · 0.85
DeleteMethod · 0.85

Calls 10

_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

Tested by

no test coverage detected