Module: Homebrew::Search::Extension

Defined in:
brew/Library/Homebrew/extend/os/mac/search.rb

Instance Method Summary collapse

Instance Method Details

#search_casks(string_or_regex) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'brew/Library/Homebrew/extend/os/mac/search.rb', line 22

def search_casks(string_or_regex)
  if string_or_regex.is_a?(String) && string_or_regex.match?(HOMEBREW_TAP_CASK_REGEX)
    return begin
      [Cask::CaskLoader.load(string_or_regex).token]
    rescue Cask::CaskUnavailableError
      []
    end
  end

  results = Cask::Cask.search(string_or_regex, &:token).sort_by(&:token)

  results.map do |cask|
    if cask.installed?
      pretty_installed(cask.token)
    else
      cask.token
    end
  end
end

#search_descriptions(string_or_regex) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'brew/Library/Homebrew/extend/os/mac/search.rb', line 9

def search_descriptions(string_or_regex)
  super

  puts

  ohai "Casks"
  Cask::Cask.to_a.extend(Searchable)
            .search(string_or_regex, &:name)
            .each do |cask|
    puts "#{Tty.bold}#{cask.token}:#{Tty.reset} #{cask.name.join(", ")}"
  end
end