#!/usr/bin/env php
<?php

/**
 * Mock Data Generator CLI
 *
 * Provides command-line interface for mock data operations:
 * - run              Run mock data generator for current time
 * - simulate-day     Simulate an entire business day
 * - backfill         Backfill missing historical data
 * - status           Show data coverage status
 *
 * Usage:
 *   php userfrosting/bin/mock run [--store=ou00] [--force]
 *   php userfrosting/bin/mock simulate-day 2025-01-01 [--store=ou00]
 *   php userfrosting/bin/mock backfill [--store=ou00] [--days=30] [--limit=5]
 *   php userfrosting/bin/mock status [--store=ou00] [--days=30]
 */

// Prevent web access
if (php_sapi_name() !== 'cli') {
    die('This script must be run from the command line.');
}

// Set up error reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');

// Ensure Slim environment bootstrap has required server keys in CLI context
$_SERVER['REQUEST_METHOD'] ??= 'CLI';
$_SERVER['REMOTE_ADDR'] ??= '127.0.0.1';
$_SERVER['REQUEST_URI'] ??= '/';

// Change to the userfrosting directory for proper path resolution
$ufDir = dirname(__DIR__);
chdir($ufDir);

// Load the application bootstrap
require_once $ufDir . '/initialize.php';

// Build and run the command handler
$command = new \BuyerKiosk\Mock\Commands\MockCommand();
$exitCode = $command->run($argv);

exit($exitCode);
