brew/Library/Homebrew/cask/cmd/outdated.rb
Frank Lam f2fa2c5d30
Add JSON support to brew cask outdated
* brew outdated already has JSON support, now users and tools can get
similar results with brew cask outdated --json
2020-04-26 21:13:19 +08:00

31 lines
770 B
Ruby

# frozen_string_literal: true
module Cask
class Cmd
class Outdated < AbstractCommand
option "--greedy", :greedy, false
option "--quiet", :quiet, false
option "--json", :json, false
def initialize(*)
super
self.verbose = ($stdout.tty? || verbose?) && !quiet?
@outdated_casks = casks(alternative: -> { Caskroom.casks }).select do |cask|
odebug "Checking update info of Cask #{cask}"
cask.outdated?(greedy?)
end
end
def run
output = @outdated_casks.map { |cask| cask.outdated_info(greedy?, verbose?, json?) }
puts json? ? JSON.generate(output) : output
end
def self.help
"list the outdated installed Casks"
end
end
end
end