Merge pull request #2311 from nath/highlightInstalledCasks
Added highlighting of installed casks to cask search
This commit is contained in:
commit
e9e6dcf893
@ -39,7 +39,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
if exact_match
|
if exact_match
|
||||||
ohai "Exact match"
|
ohai "Exact match"
|
||||||
puts exact_match
|
puts highlight_installed exact_match
|
||||||
end
|
end
|
||||||
|
|
||||||
return if partial_matches.empty?
|
return if partial_matches.empty?
|
||||||
@ -49,7 +49,12 @@ module Hbc
|
|||||||
else
|
else
|
||||||
ohai "Partial matches"
|
ohai "Partial matches"
|
||||||
end
|
end
|
||||||
puts Formatter.columns(partial_matches)
|
puts Formatter.columns(partial_matches.map(&method(:highlight_installed)))
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.highlight_installed(token)
|
||||||
|
return token unless Cask.new(token).installed?
|
||||||
|
pretty_installed token
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.help
|
def self.help
|
||||||
|
|||||||
@ -56,4 +56,16 @@ describe Hbc::CLI::Search, :cask do
|
|||||||
Hbc::CLI::Search.run("caskroom")
|
Hbc::CLI::Search.run("caskroom")
|
||||||
}.to output(/^No Cask found for "caskroom"\.\n/).to_stdout
|
}.to output(/^No Cask found for "caskroom"\.\n/).to_stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't highlight packages that aren't installed" do
|
||||||
|
expect(Hbc::CLI::Search.highlight_installed("local-caffeine")).to eq("local-caffeine")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "highlights installed packages" do
|
||||||
|
shutup do
|
||||||
|
Hbc::CLI::Install.run("local-caffeine")
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(Hbc::CLI::Search.highlight_installed("local-caffeine")).to eq(pretty_installed("local-caffeine"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user