MCPcopy Create free account
hub / github.com/cocoindex-io/cocoindex-code / search

Function search

src/cocoindex_code/cli.py:627–659  ·  view source on GitHub ↗

Semantic search across the codebase.

(
    query: list[str] = _typer.Argument(..., help="Search query"),
    lang: list[str] = _typer.Option([], "--lang", help="Filter by language"),
    path: str | None = _typer.Option(None, "--path", help="Filter by file path glob"),
    offset: int = _typer.Option(0, "--offset", help="Number of results to skip"),
    limit: int = _typer.Option(10, "--limit", help="Maximum results to return"),
    refresh: bool = _typer.Option(False, "--refresh", help="Refresh index before searching"),
)

Source from the content-addressed store, hash-verified

625@app.command()
626@_catch_daemon_start_error
627def search(
628 query: list[str] = _typer.Argument(..., help="Search query"),
629 lang: list[str] = _typer.Option([], "--lang", help="Filter by language"),
630 path: str | None = _typer.Option(None, "--path", help="Filter by file path glob"),
631 offset: int = _typer.Option(0, "--offset", help="Number of results to skip"),
632 limit: int = _typer.Option(10, "--limit", help="Maximum results to return"),
633 refresh: bool = _typer.Option(False, "--refresh", help="Refresh index before searching"),
634) -> None:
635 """Semantic search across the codebase."""
636 project_root = str(require_project_root())
637 query_str = " ".join(query)
638
639 if refresh:
640 _run_index_with_progress(project_root)
641
642 # Default path filter from CWD
643 paths: list[str] | None = None
644 if path is not None:
645 paths = [path]
646 else:
647 default = resolve_default_path(Path(project_root))
648 if default is not None:
649 paths = [default]
650
651 resp = _search_with_wait_spinner(
652 project_root=project_root,
653 query=query_str,
654 languages=lang or None,
655 paths=paths,
656 limit=limit,
657 offset=offset,
658 )
659 print_search_results(resp)
660
661
662@app.command()

Callers

nothing calls this directly

Calls 5

require_project_rootFunction · 0.85
_run_index_with_progressFunction · 0.85
resolve_default_pathFunction · 0.85
print_search_resultsFunction · 0.85

Tested by

no test coverage detected