From 34d0f4ffabcabc2a67a8d94389a6e1d130285107 Mon Sep 17 00:00:00 2001 From: Benjamin Gandon Date: Tue, 21 Jul 2015 14:40:08 +0200 Subject: [PATCH] Also display installed versions in brew-cask info Because brew-cask info does not always display installed versions, this code runs throught versions in metadata and displays info about them. --- lib/hbc/cli/info.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/hbc/cli/info.rb b/lib/hbc/cli/info.rb index 1bb9298a8e4d..bbaec6251d43 100644 --- a/lib/hbc/cli/info.rb +++ b/lib/hbc/cli/info.rb @@ -15,6 +15,24 @@ def self.help end def self.info(cask) + out = info_report(cask) + metadata_versions_glob = Pathname.glob(cask.metadata_master_container_path.join('*')) + glob_size = metadata_versions_glob.size + if glob_size > 0 then + out << "\n#{glob_size} locally known version#{glob_size > 1 ? 's' : ''}:\n" + end + metadata_versions_glob.each do |ver_path| + out << "\n" + latest_timespamped_path = Pathname.glob(ver_path.join('*')).sort.last + src_path = latest_timespamped_path.join('Casks').join("#{cask.token}.rb") + out << "#{src_path}\n" + backedup_cask = Hbc::Source.for_query(src_path).load + out << info_report(backedup_cask) + end + out + end + + def self.info_report(cask) installation = if cask.installed? "#{cask.staged_path} (#{Hbc::Utils.cabv(cask.staged_path)})" else