2016-04-08 16:28:43 +02:00
|
|
|
#: * `outdated` [`--quiet`|`--verbose`|`--json=v1`]:
|
|
|
|
#: Show formulae that have an updated version available.
|
|
|
|
#:
|
|
|
|
#: By default, version information is displayed in interactive shells, and
|
|
|
|
#: suppressed otherwise.
|
|
|
|
#:
|
|
|
|
#: If `--quiet` is passed, list only the names of outdated brews (takes
|
|
|
|
#: precedence over `--verbose`).
|
|
|
|
#:
|
|
|
|
#: If `--verbose` is passed, display detailed version information.
|
|
|
|
#:
|
|
|
|
#: If `--json=`<version> is passed, the output will be in JSON format. The only
|
|
|
|
#: valid version is `v1`.
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
require "formula"
|
|
|
|
require "keg"
|
2010-09-11 20:22:54 +01:00
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2010-09-11 20:22:54 +01:00
|
|
|
def outdated
|
2016-08-05 22:01:32 +08:00
|
|
|
formulae = if ARGV.resolved_formulae.empty?
|
|
|
|
Formula.installed
|
|
|
|
else
|
|
|
|
ARGV.resolved_formulae
|
|
|
|
end
|
2014-07-06 11:41:03 -04:00
|
|
|
if ARGV.json == "v1"
|
2015-06-26 15:15:51 +08:00
|
|
|
outdated = print_outdated_json(formulae)
|
2014-07-06 11:41:03 -04:00
|
|
|
else
|
2015-06-26 15:15:51 +08:00
|
|
|
outdated = print_outdated(formulae)
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
2016-08-05 22:01:32 +08:00
|
|
|
Homebrew.failed = !ARGV.resolved_formulae.empty? && !outdated.empty?
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
2015-06-26 15:15:51 +08:00
|
|
|
def print_outdated(formulae)
|
2015-06-25 19:33:47 -04:00
|
|
|
verbose = ($stdout.tty? || ARGV.verbose?) && !ARGV.flag?("--quiet")
|
|
|
|
|
2015-11-27 15:11:00 +00:00
|
|
|
formulae.select(&:outdated?).each do |f|
|
2015-06-25 19:33:47 -04:00
|
|
|
if verbose
|
2015-11-27 15:11:00 +00:00
|
|
|
puts "#{f.full_name} (#{f.outdated_versions*", "} < #{f.pkg_version})"
|
2014-07-06 11:41:03 -04:00
|
|
|
else
|
|
|
|
puts f.full_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-26 15:15:51 +08:00
|
|
|
def print_outdated_json(formulae)
|
2014-07-06 11:41:03 -04:00
|
|
|
json = []
|
2015-11-27 15:11:00 +00:00
|
|
|
outdated = formulae.select(&:outdated?).each do |f|
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
json << { :name => f.full_name,
|
2015-11-27 15:11:00 +00:00
|
|
|
:installed_versions => f.outdated_versions.collect(&:to_s),
|
2015-08-03 13:09:07 +01:00
|
|
|
:current_version => f.pkg_version.to_s }
|
2014-07-06 11:41:03 -04:00
|
|
|
end
|
|
|
|
puts Utils::JSON.dump(json)
|
|
|
|
|
|
|
|
outdated
|
|
|
|
end
|
2011-09-11 13:06:05 -07:00
|
|
|
end
|