#!/usr/bin/env ruby
# Initialize docs/adr/ + empty generated index in a project, and clear any
# session-hook suppression flag (.os-adr/suppress).
#
# Usage: adr-init [--root DIR]

require "fileutils"
require_relative "../lib/adr"

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

repo = Adr::Repository.new(root: root)
FileUtils.mkdir_p(repo.dir)
Adr::Index.new(repository: repo).regenerate!

suppress = File.join(root, ".os-adr", "suppress")
File.delete(suppress) if File.exist?(suppress)

puts repo.dir
