7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/dev_context/commands/doctor.rb', line 7
def cmd_doctor
return usage_error("dx doctor") unless argv.empty?
checks = []
checks.concat(shell_integration_checks)
checks.concat(config_structure_checks)
checks.concat(repo_integrity_checks)
checks.concat(environment_checks)
label_w = [checks.map { |c| c[:label].length }.max || 0, "Check".length].max
state_w = [checks.map { |c| c[:state].length }.max || 0, "State".length].max
out.puts(format("%-#{state_w}s %-#{label_w}s %s", "State", "Check", "Message"))
out.puts(format("%-#{state_w}s %-#{label_w}s %s", "-" * state_w, "-" * label_w, "-" * 7))
checks.each do |check|
out.puts(format("%-#{state_w}s %-#{label_w}s %s", check[:state], check[:label], check[:message]))
end
failures = checks.count { |c| c[:state] == "FAIL" }
warnings = checks.count { |c| c[:state] == "WARN" }
out.puts
out.puts("doctor summary: #{checks.length} checks, #{failures} failures, #{warnings} warnings")
failures.zero? ? 0 : 1
end
|