Class: CLAide::Command::Plugins::Search
- Inherits:
-
CLAide::Command::Plugins
- Object
- CLAide::Command
- CLAide::Command::Plugins
- CLAide::Command::Plugins::Search
- Defined in:
- lib/claide/command/plugins/search.rb
Overview
The search subcommand. Used to search a plugin in the list of known plugins, searching into the name, author description fields
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Search
constructor
A new instance of Search.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Search
Returns a new instance of Search.
31 32 33 34 35 |
# 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 |
Class Method Details
.options ⇒ Object
25 26 27 28 29 |
# File 'lib/claide/command/plugins/search.rb', line 25 def self. [ ['--full', 'Search by name, author, and description'], ].concat(super.reject { |option, _| option == '--silent' }) end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# 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! ⇒ Object
37 38 39 40 41 42 43 44 45 |
# 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 |