Class: Moult::CLI::GateCommand

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

Overview

moult gate [PATH] — the diff-aware PR risk gate. Thin layer: parse options, build the index + Rails awareness, resolve the policy (defaults, overridable via .moult.yml), drive Gate.build_report, hand the GateReport to a formatter. Holds NO policy logic.

Exit code (the one command in Moult that renders a verdict, so it is the one exception to the repo-wide "1 = error" convention):

0 = gate passed
1 = gate failed (policy violated)
2 = tool error (bad option, missing path, unresolvable diff, …)

Constant Summary collapse

PASS =
0
FAIL =
1
ERROR =
2

Instance Method Summary collapse

Instance Method Details

#run(argv) ⇒ Integer

Returns process exit status.

Returns:

  • (Integer)

    process exit status



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/moult/cli/gate_command.rb', line 24

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

  execute(options)
rescue OptionParser::ParseError, Moult::Error => e
  warn "moult: #{e.message}"
  ERROR
rescue => e
  warn "moult: #{e.message}"
  ERROR
end