diff options
| author | Markus Reiter | 2017-01-22 04:28:33 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-01-23 09:33:12 +0100 |
| commit | 16f4130dd81b45df697699f5bac7fa54489e8291 (patch) | |
| tree | 7a2df34dbc44eacc7b2d9d742ab3330b667e91e3 /Library/Homebrew/cask/lib/hbc/cli | |
| parent | 3be56aee71da207dbc491b5d9bfd803fb8201f9a (diff) | |
| download | brew-16f4130dd81b45df697699f5bac7fa54489e8291.tar.bz2 | |
Add internal command to calculate appcast checkpoint.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cli')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb new file mode 100644 index 000000000..6de76cbc7 --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -0,0 +1,45 @@ +module Hbc + class CLI + class InternalAppcastCheckpoint < InternalUseBase + def self.run(*args) + cask_tokens = cask_tokens_from(args) + raise CaskUnspecifiedError if cask_tokens.empty? + + appcask_checkpoint(cask_tokens) + end + + def self.appcask_checkpoint(cask_tokens) + count = 0 + + cask_tokens.each do |cask_token| + cask = Hbc.load(cask_token) + + if cask.appcast.nil? + opoo "Cask '#{cask}' is missing an `appcast` stanza." + else + result = cask.appcast.calculate_checkpoint + + checkpoint = result[:checkpoint] + + if checkpoint.nil? + onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" + else + puts cask_tokens.count > 1 ? "#{checkpoint} #{cask}": checkpoint + count += 1 + end + end + end + + count == cask_tokens.count + end + + def self.help + "calculates a given Cask's appcast checkpoint" + end + + def self.needs_init? + true + end + end + end +end |
