diff options
| author | Markus Reiter | 2017-09-11 05:19:05 +0200 |
|---|---|---|
| committer | GitHub | 2017-09-11 05:19:05 +0200 |
| commit | f3ec40d696b421e89f462d32f6f30a81f60d3e73 (patch) | |
| tree | 24b370322f96e962917bb356408132dc9a4dfb3d /Library/Homebrew/cask/lib/hbc/cli | |
| parent | 5bcce735ddd7b68da6bde7dec6ca318c7801aade (diff) | |
| parent | b0c98ba6319e0e53cc0a262dd08bbb339d4bd7b5 (diff) | |
| download | brew-f3ec40d696b421e89f462d32f6f30a81f60d3e73.tar.bz2 | |
Merge pull request #3141 from reitermarkus/single-artifacts
Make artifacts singular.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/info.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 68 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/list.rb | 6 |
3 files changed, 36 insertions, 50 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/info.rb b/Library/Homebrew/cask/lib/hbc/cli/info.rb index d26747e17..9cdada62e 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/info.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/info.rb @@ -69,13 +69,11 @@ module Hbc def self.artifact_info(cask) ohai "Artifacts" - DSL::ORDINARY_ARTIFACT_TYPES.each do |type| - next if cask.artifacts[type].empty? - cask.artifacts[type].each do |artifact| - activatable_item = (type == :stage_only) ? "<none>" : artifact.first - puts "#{activatable_item} (#{type})" - end - end + DSL::ORDINARY_ARTIFACT_CLASSES.flat_map { |klass| klass.for_cask(cask) } + .select { |artifact| artifact.respond_to?(:install_phase) } + .each do |artifact| + puts artifact.to_s + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index 4515fe931..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,41 +14,16 @@ 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 # - # TODO: this should be retrievable from Hbc::DSL - ARTIFACTS = Set.new [ - :app, - :suite, - :artifact, - :prefpane, - :qlplugin, - :dictionary, - :font, - :service, - :colorpicker, - :binary, - :input_method, - :internet_plugin, - :audio_unit_plugin, - :vst_plugin, - :vst3_plugin, - :screen_saver, - :pkg, - :installer, - :stage_only, - :nested_container, - :uninstall, - :preflight, - :postflight, - :uninstall_preflight, - :uninstall_postflight, - ] + ARTIFACTS = + DSL::ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key) + + DSL::ARTIFACT_BLOCK_CLASSES.map(&:dsl_key) option "--table", :table, false option "--quiet", :quiet, false @@ -68,7 +43,6 @@ module Hbc @stanza = args.shift.to_sym @format = :to_yaml if yaml? - @format = :inspect if inspect? end def run @@ -93,7 +67,7 @@ module Hbc end begin - value = cask.send(@stanza) + value = cask.send(stanza) rescue StandardError opoo "failure calling '#{stanza}' on Cask '#{cask}'" unless quiet? puts "" @@ -106,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 - if @format - puts value.send(@format) - elsif artifact_name || value.is_a?(Symbol) + [k, v] + end + ] + + value = value.fetch(artifact_name) if artifact_name + end + + if format + puts value.send(format) + elsif value.is_a?(Symbol) puts value.inspect else puts value.to_s diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 9d978360e..4b5fcd873 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -30,9 +30,9 @@ module Hbc end def self.list_artifacts(cask) - Artifact.for_cask(cask).each do |artifact| - summary = artifact.summary - ohai summary[:english_description], summary[:contents] unless summary.empty? + Artifact.for_cask(cask).group_by(&:class).each do |klass, artifacts| + next unless klass.respond_to?(:english_description) + ohai klass.english_description, artifacts.map(&:summarize_installed) end end |
