brew/Library/Homebrew/cmd/doctor.rb

78 lines
2.1 KiB
Ruby
Raw Normal View History

require "diagnostic"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2018-10-24 15:58:35 +05:30
def doctor_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`doctor` [<options>]
Check your system for potential problems. Doctor exits with a non-zero status
if any potential problems are found. Please note that these warnings are just
used to help the Homebrew maintainers with debugging if you file an issue. If
everything you use Homebrew for is working fine: please don't worry or file
an issue; just ignore this.
EOS
switch "--list-checks",
description: "List all audit methods."
switch "-D", "--audit-debug",
description: "Enable debugging and profiling of audit methods."
switch :verbose
switch :debug
end
end
2010-11-09 13:00:33 +00:00
def doctor
2018-10-24 15:58:35 +05:30
doctor_args.parse
inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug?
checks = Diagnostic::Checks.new
2018-10-24 15:58:35 +05:30
if args.list_checks?
puts checks.all.sort
2012-11-13 16:49:43 -06:00
exit
end
if ARGV.named.empty?
slow_checks = %w[
check_for_broken_symlinks
check_missing_deps
]
methods = (checks.all.sort - slow_checks) + slow_checks
else
methods = ARGV.named
end
first_warning = true
methods.each do |method|
2018-10-24 15:58:35 +05:30
$stderr.puts "Checking #{method}" if args.debug?
unless checks.respond_to?(method)
Homebrew.failed = true
puts "No check available by the name: #{method}"
next
end
out = checks.send(method)
2016-09-10 10:24:56 +01:00
next if out.nil? || out.empty?
2018-09-17 02:45:00 +02:00
2016-09-10 10:24:56 +01:00
if first_warning
2017-10-15 02:28:32 +02:00
$stderr.puts <<~EOS
2016-08-30 21:38:13 +02:00
#{Tty.bold}Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!#{Tty.reset}
2016-09-10 10:24:56 +01:00
EOS
end
2016-09-10 10:24:56 +01:00
$stderr.puts
opoo out
Homebrew.failed = true
first_warning = false
end
2010-11-09 13:00:33 +00:00
puts "Your system is ready to brew." unless Homebrew.failed?
end
end