aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/cli
diff options
context:
space:
mode:
authorMarkus Reiter2017-08-04 14:59:18 +0200
committerMarkus Reiter2017-09-10 23:12:32 +0200
commitb0c98ba6319e0e53cc0a262dd08bbb339d4bd7b5 (patch)
tree24b370322f96e962917bb356408132dc9a4dfb3d /Library/Homebrew/cask/lib/hbc/cli
parent53ecdd843f6e6d6dd93e09a5394de3c31bc0e51a (diff)
downloadbrew-b0c98ba6319e0e53cc0a262dd08bbb339d4bd7b5.tar.bz2
Fix `_stanza`.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb31
1 files changed, 22 insertions, 9 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
index 2727f95b7..018b4e9ca 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
@@ -3,7 +3,7 @@ module Hbc
class InternalStanza < AbstractInternalCommand
# Syntax
#
- # brew cask _stanza <stanza_name> [ --table | --yaml | --inspect | --quiet ] [ <cask_token> ... ]
+ # brew cask _stanza <stanza_name> [ --quiet ] [ --table | --yaml ] [ <cask_token> ... ]
#
# If no tokens are given, then data for all Casks is returned.
#
@@ -14,11 +14,11 @@ module Hbc
# Examples
#
# brew cask _stanza appcast --table
- # brew cask _stanza app --table alfred google-chrome adium voicemac logisim vagrant
- # brew cask _stanza url --table alfred google-chrome adium voicemac logisim vagrant
- # brew cask _stanza version --table alfred google-chrome adium voicemac logisim vagrant
- # brew cask _stanza artifacts --table --inspect alfred google-chrome adium voicemac logisim vagrant
- # brew cask _stanza artifacts --table --yaml alfred google-chrome adium voicemac logisim vagrant
+ # brew cask _stanza app --table alfred google-chrome adium vagrant
+ # brew cask _stanza url --table alfred google-chrome adium vagrant
+ # brew cask _stanza version --table alfred google-chrome adium vagrant
+ # brew cask _stanza artifacts --table alfred google-chrome adium vagrant
+ # brew cask _stanza artifacts --table --yaml alfred google-chrome adium vagrant
#
ARTIFACTS =
@@ -43,7 +43,6 @@ module Hbc
@stanza = args.shift.to_sym
@format = :to_yaml if yaml?
- @format = :inspect if inspect?
end
def run
@@ -81,11 +80,25 @@ module Hbc
next
end
- value = value.fetch(artifact_name).to_a.flatten if artifact_name
+ if stanza == :artifacts
+ value = Hash[
+ value.map do |k, v|
+ v = v.map do |a|
+ next a.to_a if a.respond_to?(:to_a)
+ next a.to_h if a.respond_to?(:to_h)
+ a
+ end
+
+ [k, v]
+ end
+ ]
+
+ value = value.fetch(artifact_name) if artifact_name
+ end
if format
puts value.send(format)
- elsif artifact_name || value.is_a?(Symbol)
+ elsif value.is_a?(Symbol)
puts value.inspect
else
puts value.to_s