Sha256: 8a5f43e263efeb39ce7f9dfc83e9c3f83300c341be6c88a7b5ae8b62d804b2be

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'pod/command/plugins_helper'

module Pod
  class Command
    class Plugins
      # The search subcommand.
      # Used to search a plugin in the list of known plugins,
      # searching into the name, author description fields
      #
      class Search < Plugins
        self.summary = 'Search for known plugins'
        self.description = <<-DESC
                Searches plugins whose name contains the given text
                (ignoring case).

                With --full, it also searches by author and description.
        DESC

        self.arguments = [
          ['QUERY', :required]
        ]

        def self.options
          [
            ['--full',  'Search by name, author, and description']
          ].concat(super.reject { |option, _| option == '--silent' })
        end

        def initialize(argv)
          @full_text_search = argv.flag?('full')
          @query = argv.shift_argument unless argv.arguments.empty?
          super
        end

        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

        def run
          plugins = PluginsHelper.matching_plugins(@query, @full_text_search)

          UI.title "Available CocoaPods Plugins matching '#{@query}':"
          plugins.each do |plugin|
            PluginsHelper.print_plugin plugin, self.verbose?
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cocoapods-plugins-0.2.0 lib/pod/command/plugins/search.rb