diff --git a/src/cli/commands.py b/src/cli/commands.py index f3bb15a..4aa5d04 100644 --- a/src/cli/commands.py +++ b/src/cli/commands.py @@ -1,7 +1,6 @@ """CLI command definitions.""" from pathlib import Path -from typing import Optional import click from rich.console import Console @@ -16,9 +15,7 @@ from src.utils.formatters import ( format_index_summary, format_search_results, format_success, - format_help_header, ) -from src.utils.config import reset_config console = Console() @@ -32,7 +29,7 @@ def cli(ctx, verbose): ctx.obj["verbose"] = verbose -@click.command(name="index") +@cli.command(name="index") @click.argument( "path", type=click.Path(exists=True, file_okay=True, dir_okay=True, path_type=Path) ) @@ -55,8 +52,6 @@ def index_command(ctx, path, type, recursive, batch_size): PATH is the path to a file or directory to index. """ - verbose = ctx.obj.get("verbose", False) - with console.status(f"Indexing {type} documentation from {path}..."): searcher = Searcher() count = searcher.index(path, doc_type=type, recursive=recursive, batch_size=batch_size) @@ -69,7 +64,7 @@ def index_command(ctx, path, type, recursive, batch_size): console.print("Try specifying a type: --type openapi|readme|code") -@click.command(name="search") +@cli.command(name="search") @click.argument("query", type=str) @click.option( "--limit", "-l", type=int, default=None, help="Maximum number of results" @@ -97,10 +92,6 @@ def search_command(ctx, query, limit, type, json, hybrid): if limit is None: limit = config.default_limit - source_filter = None - if type: - source_filter = SourceType(type) - searcher = Searcher() with console.status("Searching..."): @@ -124,7 +115,7 @@ def search_command(ctx, query, limit, type, json, hybrid): console.print(f"\nFound {len(results)} result(s)") -@click.command(name="list") +@cli.command(name="list") @click.option( "--type", "-t", @@ -135,10 +126,6 @@ def search_command(ctx, query, limit, type, json, hybrid): @click.pass_context def list_command(ctx, type, json): """List indexed documents.""" - source_filter = None - if type: - source_filter = SourceType(type) - searcher = Searcher() stats = searcher.get_stats() @@ -156,7 +143,7 @@ def list_command(ctx, type, json): console.print(table) -@click.command(name="stats") +@cli.command(name="stats") @click.pass_context def stats_command(ctx): """Show index statistics.""" @@ -172,7 +159,7 @@ def stats_command(ctx): console.print(table) -@click.command(name="clear") +@cli.command(name="clear") @click.option("--type", "-t", type=click.Choice(["openapi", "readme", "code"])) @click.option("--force", "-f", is_flag=True, help="Skip confirmation prompt") @click.pass_context @@ -202,7 +189,7 @@ def clear_command(ctx, type, force): console.print(format_success(f"Deleted {count} document(s)")) -@click.command(name="config") +@cli.command(name="config") @click.option("--show", is_flag=True, help="Show current configuration") @click.option("--reset", is_flag=True, help="Reset configuration to defaults") @click.pass_context @@ -234,7 +221,7 @@ def config_command(ctx, show, reset): console.print(panel) -@click.command(name="interactive") +@cli.command(name="interactive") @click.pass_context def interactive_command(ctx): """Enter interactive search mode."""