Class: Moult::CLI::HealthCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/moult/cli/health_command.rb

Overview

moult health [PATH] — a composite, auditable health score aggregated from the other analyses. Thin layer: parse options, build the index + Rails awareness (+ optional coverage), drive Health.build_report, hand the HealthReport to a formatter. Report-only: exit 0 on success (even on a low score — the PR gate is Phase 4), non-zero only on a hard error.

Constant Summary collapse

VALID_COVERAGE_FORMATS =
%i[auto simplecov coverage].freeze

Instance Method Summary collapse

Instance Method Details

#run(argv) ⇒ Integer

Returns process exit status.

Returns:

  • (Integer)

    process exit status



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/moult/cli/health_command.rb', line 17

def run(argv)
  options = parse(argv)
  return puts_help(options) if options[:help]

  root = File.expand_path(options[:path])
  unless File.exist?(root)
    warn "moult: no such file or directory: #{options[:path]}"
    return 1
  end

  report = analyze(root, options)
  puts render(report, options)
  0
rescue OptionParser::ParseError => e
  warn "moult: #{e.message}"
  1
rescue => e
  warn "moult: #{e.message}"
  1
end