class CLAide::Command::Plugins::Search

The search subcommand. Used to search a plugin in the list of known plugins, searching into the name, author description fields

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/claide/command/plugins/search.rb, line 31
def initialize(argv)
  @full_text_search = argv.flag?('full')
  @query = argv.shift_argument unless argv.arguments.empty?
  super
end
options() click to toggle source
Calls superclass method
# File lib/claide/command/plugins/search.rb, line 25
def self.options
  [
    ['--full',  'Search by name, author, and description'],
  ].concat(super.reject { |option, _| option == '--silent' })
end

Public Instance Methods

run() click to toggle source
# File lib/claide/command/plugins/search.rb, line 47
def run
  plugins = PluginsHelper.matching_plugins(@query, @full_text_search)
  GemHelper.download_and_cache_specs if self.verbose?

  name = CLAide::Plugins.config.name
  UI.title "Available #{name} Plugins matching '#{@query}':"
  plugins.each do |plugin|
    PluginsHelper.print_plugin plugin, self.verbose?
  end
end
validate!() click to toggle source
Calls superclass method
# File lib/claide/command/plugins/search.rb, line 37
def validate!
  super
  help! 'A search query is required.' if @query.nil? || @query.empty?
  begin
    /#{@query}/
  rescue RegexpError
    help! 'A valid regular expression is required.'
  end
end