#!/usr/bin/env ruby
# Classify existing ADR-like content into surveyed shapes and enumerate
# migration units. Report-only: writes nothing.
#
# Usage: adr-detect [--root DIR]   ->  JSON on stdout

require "json"
require_relative "../lib/adr"

root = Dir.pwd
ARGV.each_with_index { |arg, i| root = ARGV[i + 1] if arg == "--root" }

units = Adr::Detector.new(root: root).units.map do |unit|
  { "shape" => unit.shape.to_s, "source" => unit.source_ref, "title" => unit.title }
end
puts JSON.pretty_generate("units" => units)
