Skip to content
Snippets Groups Projects
Commit 53e232fc authored by Vítor Galvão's avatar Vítor Galvão Committed by Markus Reiter
Browse files

Add --calculate (print current checkpoint without it)

parent 2de6d96a
No related branches found
No related tags found
No related merge requests found
...@@ -2,13 +2,14 @@ module Hbc ...@@ -2,13 +2,14 @@ module Hbc
class CLI class CLI
class InternalAppcastCheckpoint < InternalUseBase class InternalAppcastCheckpoint < InternalUseBase
def self.run(*args) def self.run(*args)
calculate = args.include? "--calculate"
cask_tokens = cask_tokens_from(args) cask_tokens = cask_tokens_from(args)
raise CaskUnspecifiedError if cask_tokens.empty? raise CaskUnspecifiedError if cask_tokens.empty?
appcask_checkpoint(cask_tokens) appcask_checkpoint(cask_tokens, calculate)
end end
def self.appcask_checkpoint(cask_tokens) def self.appcask_checkpoint(cask_tokens, calculate)
count = 0 count = 0
cask_tokens.each do |cask_token| cask_tokens.each do |cask_token|
...@@ -17,9 +18,13 @@ module Hbc ...@@ -17,9 +18,13 @@ module Hbc
if cask.appcast.nil? if cask.appcast.nil?
opoo "Cask '#{cask}' is missing an `appcast` stanza." opoo "Cask '#{cask}' is missing an `appcast` stanza."
else else
result = cask.appcast.calculate_checkpoint if calculate
result = cask.appcast.calculate_checkpoint
checkpoint = result[:checkpoint] checkpoint = result[:checkpoint]
else
checkpoint = cask.appcast.checkpoint
end
if checkpoint.nil? if checkpoint.nil?
onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}"
...@@ -34,7 +39,7 @@ module Hbc ...@@ -34,7 +39,7 @@ module Hbc
end end
def self.help def self.help
"calculates a given Cask's appcast checkpoint" "prints (no flag) or calculates ('--calculate') a given Cask's appcast checkpoint"
end end
def self.needs_init? def self.needs_init?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment