<?php
/**
 * WooCommerce Dummy Data Seeder — ModaExpress Fashion Store
 *
 * Run via WP-CLI from the WordPress root:
 *   wp eval-file wp-content/plugins/woocommerce-analytics-dashboard/seed-data.php
 *
 * To remove all seeded data:
 *   wp eval-file wp-content/plugins/woocommerce-analytics-dashboard/seed-data.php -- --clean
 */

if ( ! class_exists( 'WooCommerce' ) ) {
	WP_CLI::error( 'WooCommerce is not active. Please activate WooCommerce and try again.' );
}

if ( ! class_exists( 'WAD_Seeder' ) ) {
	require_once __DIR__ . '/includes/class-seeder.php';
}

$clean = in_array( '--clean', $GLOBALS['argv'] ?? [], true );

if ( $clean ) {
	WP_CLI::log( 'Removing seeded data...' );
	$result = WAD_Seeder::clean();
	WP_CLI::success( sprintf(
		'Clean complete. Removed %d products, %d customers, %d orders.',
		$result['products'], $result['customers'], $result['orders']
	) );
} else {
	WP_CLI::log( 'Seeding demo data — this may take a minute...' );
	$result = WAD_Seeder::seed();
	WP_CLI::success( sprintf(
		'Done! Created %d products, %d customers, %d orders.',
		$result['products'], $result['customers'], $result['orders']
	) );
	WP_CLI::log( 'To remove: wp eval-file wp-content/plugins/woocommerce-analytics-dashboard/seed-data.php -- --clean' );
}
