Class: Ace::Search::CLI::Commands::Search

Inherits:
Ace::Support::Cli::Command
  • Object
show all
Includes:
Ace::Support::Cli::Base
Defined in:
lib/ace/search/cli/commands/search.rb

Overview

ace-support-cli Command class for the search command

This command handles all search functionality including file and content search across the codebase with intelligent pattern matching.

Note: CLI orchestration methods (execute_search_command, resolve_search_path) are intentionally in this class as they handle CLI-specific concerns (config display, error messages, interactive selection). Business logic is properly delegated to ATOM layers (UnifiedSearcher, SearchPathResolver).

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/ace/search/cli/commands/search.rb', line 102

def call(**options)
  # Extract pattern and search path
  @pattern = options[:pattern]
  @search_path = options[:search_path]

  # Remove ace-support-cli specific keys (args is leftover arguments)
  clean_options = options.reject { |k, _| k == :args }
  if clean_options[:version]
    puts "ace-search #{Ace::Search::VERSION}"
    return 0
  end

  # Type-convert numeric options using Base helper for proper validation
  # coerce_types uses Integer() which raises ArgumentError on invalid input
  # (unlike .to_i which silently returns 0)
  coerce_types(clean_options,
    max_results: :integer,
    context: :integer,
    after_context: :integer,
    before_context: :integer)

  # Build search options from CLI options using dedicated molecule
  @options = Ace::Search::Molecules::SearchOptionBuilder.new(clean_options).build

  # Execute search
  execute_search_command
end