#!/usr/bin/env ruby
# frozen_string_literal: true

# Ace Review - Automated review tool
#
# This executable provides review functionality for the ACE framework.
# It supports preset-based reviews with configurable focus areas using LLM analysis.

# Use absolute path resolution to support execution from any directory
lib_path = File.expand_path("../lib", __dir__)
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)

require "ace/review"
require "ace/support/cli"

# Pre-process array options before passing to ace-support-cli
# (ace-support-cli only captures the last occurrence of --subject/--model flags)
args = Ace::Review::CLI.preprocess_array_options(ARGV)
args = ["--help"] if args.empty?

# Start ace-support-cli single-command entrypoint with exception-based exit code handling (per ADR-023)
begin
  Ace::Support::Cli::Runner.new(Ace::Review::CLI::Commands::Review).call(args: args)
rescue Ace::Support::Cli::Error => e
  warn e.message
  exit(e.exit_code)
end
