Files
bx.nullable/clone.php
T
2026-09-12 10:14:11 +03:00

37 lines
916 B
PHP

<?php
declare(strict_types=1);
use Wt\Core\App\ModuleEntity;
use Wt\Core\App\ModuleCloner;
require './../wt.core/include.php';
require './ModuleCloner.php';
if (!isset($argv[1])) {
echo "Error: Please provide the target module path as the first argument." . PHP_EOL;
exit(1);
}
try {
$sourcePath = __DIR__;
$targetPath = realpath($argv[1]);
if ($targetPath === false) {
throw new InvalidArgumentException("Invalid target path: {$argv[1]}");
}
$targetEntity = __getModuleEntity($targetPath);
$sourceEntity = __getModuleEntity($sourcePath);
echo "Cloning {$sourceEntity->getId()} -> {$targetEntity->getId()}..." . PHP_EOL;
$cloner = new ModuleCloner($sourceEntity, $targetEntity);
$cloner->clone();
echo "Success: Module cloned successfully." . PHP_EOL;
} catch (Throwable $e) {
echo "Critical Error: " . $e->getMessage() . PHP_EOL;
exit(1);
}