Class: Moult::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/moult/cli.rb,
lib/moult/cli/gate_command.rb,
lib/moult/cli/flags_command.rb,
lib/moult/cli/health_command.rb,
lib/moult/cli/coverage_command.rb,
lib/moult/cli/hotspots_command.rb,
lib/moult/cli/dead_code_command.rb,
lib/moult/cli/boundaries_command.rb,
lib/moult/cli/duplication_command.rb

Overview

Thin command-line layer. Holds no analysis logic of its own: it parses options, delegates to the library, and hands the resulting Report to a formatter. Returns a process exit status (0 success, non-zero on error).

Defined Under Namespace

Modules: Support Classes: BoundariesCommand, CoverageCommand, DeadCodeCommand, DuplicationCommand, FlagsCommand, GateCommand, HealthCommand, HotspotsCommand

Constant Summary collapse

COMMANDS =

Subcommand => [require path, command class name]. Lazily required so a single command run never loads every analysis. Adding a slice is one entry here.

{
  "hotspots" => ["moult/cli/hotspots_command", :HotspotsCommand],
  "deadcode" => ["moult/cli/dead_code_command", :DeadCodeCommand],
  "coverage" => ["moult/cli/coverage_command", :CoverageCommand],
  "duplication" => ["moult/cli/duplication_command", :DuplicationCommand],
  "health" => ["moult/cli/health_command", :HealthCommand],
  "boundaries" => ["moult/cli/boundaries_command", :BoundariesCommand],
  "flags" => ["moult/cli/flags_command", :FlagsCommand],
  "gate" => ["moult/cli/gate_command", :GateCommand]
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(argv) ⇒ Object



47
48
49
# File 'lib/moult/cli.rb', line 47

def self.start(argv)
  new.run(argv)
end

Instance Method Details

#run(argv) ⇒ Integer

Returns process exit status.

Returns:

  • (Integer)

    process exit status



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/moult/cli.rb', line 52

def run(argv)
  argv = argv.dup

  # Top-level flags that short-circuit before subcommand dispatch.
  case argv.first
  when "--version", "-v"
    puts Moult::VERSION
    return 0
  when nil, "--help", "-h"
    puts usage
    return 0
  end

  dispatch(argv.shift, argv)
end

#usageObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/moult/cli.rb', line 84

def usage
  <<~USAGE
    moult #{Moult::VERSION} — codebase intelligence for Ruby

    Usage:
      moult hotspots [PATH] [options]     Rank files by complexity x churn
      moult deadcode [PATH] [options]     List confidence-graded dead-code candidates
      moult coverage [PATH] [options]     Map symbols hot/cold/untracked from coverage
      moult duplication [PATH] [options]  List confidence-graded structural-clone groups
      moult health [PATH] [options]       Aggregate the analyses into a composite health score
      moult boundaries [PATH] [options]   List recorded architecture-boundary violations (packwerk)
      moult flags [PATH] [options]        Catalogue OpenFeature feature-flag references (usage)
      moult gate [PATH] [options]         Diff-aware PR risk gate: verdict over the changed code
      moult --version                     Print version
      moult --help                        Show this message
  USAGE
end