Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
info: decorate deps to show installed status?
Browse files Browse the repository at this point in the history
* shows green tick if installed or red cross if not
* only highlight dependency if HOMEBREW_NO_EMOJI is set

Closes #18922.

Signed-off-by: Mike McQuaid <[email protected]>
  • Loading branch information
colindean authored and MikeMcQuaid committed Nov 11, 2013
1 parent fcaef1a commit 2bc3066
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Library/Homebrew/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def info_formula f
ohai "Dependencies"
%w{build required recommended optional}.map do |type|
deps = f.deps.send(type)
puts "#{type.capitalize}: #{deps*', '}" unless deps.empty?
puts "#{type.capitalize}: #{decorate_dependencies deps}" unless deps.empty?
end
end

Expand All @@ -136,6 +136,21 @@ def info_formula f
ohai 'Caveats', c.caveats unless c.empty?
end

def decorate_dependencies dependencies
# necessary for 1.8.7 unicode handling since many installs are on 1.8.7
tick = Tty.green + ["2714".hex].pack("U*") + Tty.reset

This comment has been minimized.

Copy link
@rafaelfranca

rafaelfranca Nov 11, 2013

Contributor

Sometimes Tty.green (or any method) can return nil as you can see and nil + something else will blow up an error.

cross = Tty.red + ["2718".hex].pack("U*") + Tty.reset

deps_status = dependencies.collect do |dep|
if ENV['HOMEBREW_NO_EMOJI']
"%s%s%s" % [(dep.installed? ? Tty.green : Tty.red), dep, Tty.reset]
else
"%s %s" % [dep, (dep.installed? ? tick : cross)]
end
end
deps_status * ", "
end

private

def valid_url u
Expand Down

2 comments on commit 2bc3066

@wfarr
Copy link
Contributor

@wfarr wfarr commented on 2bc3066 Nov 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this as well.

@MikeMcQuaid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix pushed in 508cf44.

Please sign in to comment.