Module: Hashira::CLI::Usage

Defined in:
lib/hashira/cli/usage.rb

Constant Summary collapse

PAGES =
%i[help version].freeze
HEADER =
<<~TEXT
  Usage: hashira [DIRECTORY ...] [options]

  Coupling, cognitive-complexity, duplication, and code-smell metrics
  for Ruby, via Prism, rolled up per file as a ranked list of hotspots.
  With no directory, auto-detects lib/<gem>.

  Options:
TEXT
<<~TEXT

  Findings accepted by design can be recorded in the baseline as
    "accepted": [{"kind": "...", "package": "...", "reason": "..."}]
  — they leave reports and gates, keeping a one-line reminder each.
  Clones are named by "digest" instead of "package", so an acceptance
  survives the lines above it moving. Read digests from --json.
TEXT

Class Method Summary collapse

Class Method Details

.emit(output) ⇒ Object



40
41
42
43
# File 'lib/hashira/cli/usage.rb', line 40

def emit(output)
  puts(output)
  0
end

.helpObject



29
# File 'lib/hashira/cli/usage.rb', line 29

def help = emit(HEADER + options + FOOTER)

.optionsObject



33
# File 'lib/hashira/cli/usage.rb', line 33

def options = Hashira::CLI::FLAGS.map { rows(it) }.join

.rows(flag) ⇒ Object



35
36
37
38
# File 'lib/hashira/cli/usage.rb', line 35

def rows(flag)
  first, *rest = flag.text
  ["  #{flag.label.ljust(21)}#{first}\n", *rest.map { "#{" " * 23}#{it}\n" }].join
end

.versionObject



31
# File 'lib/hashira/cli/usage.rb', line 31

def version = emit("hashira #{Hashira::VERSION}")