2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-09-06 08:29:14 +02:00
|
|
|
module Cask
|
2018-09-04 08:45:48 +01:00
|
|
|
class Cmd
|
2017-05-20 19:08:03 +02:00
|
|
|
class Outdated < AbstractCommand
|
2020-08-01 02:30:46 +02:00
|
|
|
def self.description
|
|
|
|
"List the outdated installed casks."
|
|
|
|
end
|
2017-05-20 03:38:51 +02:00
|
|
|
|
2020-08-01 02:30:46 +02:00
|
|
|
def self.parser
|
|
|
|
super do
|
|
|
|
switch "--greedy",
|
|
|
|
description: "Also include casks which specify `auto_updates true` or `version :latest`."
|
|
|
|
switch "--json",
|
|
|
|
description: "Print a JSON representation of outdated casks."
|
2017-02-27 22:33:34 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-26 21:13:19 +08:00
|
|
|
def run
|
2020-08-01 02:30:46 +02:00
|
|
|
outdated_casks = casks(alternative: -> { Caskroom.casks }).select do |cask|
|
|
|
|
odebug "Checking update info of Cask #{cask}"
|
|
|
|
cask.outdated?(args.greedy?)
|
|
|
|
end
|
2017-02-27 22:33:34 +02:00
|
|
|
|
2020-08-01 02:30:46 +02:00
|
|
|
verbose = ($stdout.tty? || args.verbose?) && !args.quiet?
|
|
|
|
output = outdated_casks.map { |cask| cask.outdated_info(args.greedy?, verbose, args.json?) }
|
2017-02-27 22:33:34 +02:00
|
|
|
|
2020-08-01 02:30:46 +02:00
|
|
|
puts args.json? ? JSON.generate(output) : output
|
2017-02-27 22:33:34 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|