Module: LanguageOperator::CLI::Commands::Tool::Search
- Included in:
- Base
- Defined in:
- lib/language_operator/cli/commands/tool/search.rb
Overview
Tool search commands
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/language_operator/cli/commands/tool/search.rb', line 11 def self.included(base) base.class_eval do desc 'search [PATTERN]', 'Search available tools in the registry' long_desc <<-DESC Search and list available tools from the registry. Without a pattern, lists all available tools. With a pattern, filters tools by name or description (case-insensitive). Examples: langop tool search # List all tools langop tool search web # Find tools matching "web" langop tool search email # Find tools matching "email" DESC def search(pattern = nil) handle_command_error('search tools') do # Load tool patterns registry registry = Config::ToolRegistry.new patterns = registry.fetch # Filter out aliases and match pattern tools = patterns.select do |key, config| next false if config['alias'] # Skip aliases if pattern # Case-insensitive match on name or description key.downcase.include?(pattern.downcase) || config['description']&.downcase&.include?(pattern.downcase) else true end end if tools.empty? if pattern Formatters::ProgressFormatter.info("No tools found matching '#{pattern}'") else Formatters::ProgressFormatter.info('No tools found in registry') end return end # Display tools in a nice format tools.each do |name, config| description = config['description'] || 'No description' # Bold the tool name (ANSI escape codes) bold_name = "\e[1m#{name}\e[0m" puts "#{bold_name} - #{description}" end end end end end |