-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdevtb-php
More file actions
executable file
·71 lines (58 loc) · 2.39 KB
/
Copy pathdevtb-php
File metadata and controls
executable file
·71 lines (58 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env php
<?php
/**
* DEVTB - DevelopmentTranslation Bridge CLI
*
* Command-line interface for the Translation Bridge™
* Converts between 14 page builder frameworks with AI optimization
*
* @package DevelopmentTranslation_Bridge
* @subpackage CLI
* @version 5.1.0
* @author DevelopmentTranslation Bridge
* @license GPL-2.0+
*/
// Prevent direct access
if (php_sapi_name() !== 'cli') {
die('This script can only be run from the command line.' . PHP_EOL);
}
// Define constants
if (!defined('DEVTB_CLI')) { define('DEVTB_CLI', true); }
if (!defined('DEVTB_VERSION')) { define('DEVTB_VERSION', '5.1.0'); }
if (!defined('DEVTB_ROOT')) { define('DEVTB_ROOT', __DIR__); }
if (!defined('DEVTB_INCLUDES')) { define('DEVTB_INCLUDES', DEVTB_ROOT . '/includes'); }
if (!defined('DEVTB_TRANSLATION_BRIDGE')) { define('DEVTB_TRANSLATION_BRIDGE', DEVTB_ROOT . '/translation-bridge'); }
// Check PHP version
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
fwrite(STDERR, "\033[31mError: DEVTB requires PHP 8.1.0 or higher. You are running " . PHP_VERSION . "\033[0m" . PHP_EOL);
exit(1);
}
// Shared autoloader (resolves DEVTB\TranslationBridge\... and global DEVTB_* classes).
require_once DEVTB_INCLUDES . '/class-devtb-autoloader.php';
devtb_register_autoloader();
// WordPress function stubs for CLI mode (esc_attr, get_option, etc.). No-op under WP.
require_once DEVTB_INCLUDES . '/wp-function-stubs.php';
// Pre-load the CLI bootstrap classes (cheaper than autoloader cold-start; no functional dependency).
require_once DEVTB_INCLUDES . '/class-devtb-cli.php';
require_once DEVTB_INCLUDES . '/class-devtb-file-handler.php';
require_once DEVTB_INCLUDES . '/class-devtb-logger.php';
// Main execution
try {
// Get command line arguments
$args = array_slice($argv, 1);
// Initialize CLI handler
$cli = new DEVTB_CLI($args);
// Execute command
$exit_code = $cli->execute();
// Exit with appropriate code
exit($exit_code);
} catch (Exception $e) {
// Handle fatal errors
fwrite(STDERR, "\033[31m✗ Fatal Error: " . $e->getMessage() . "\033[0m" . PHP_EOL);
if (in_array('--debug', $args) || in_array('-d', $args)) {
fwrite(STDERR, "\nStack Trace:\n" . $e->getTraceAsString() . PHP_EOL);
} else {
fwrite(STDERR, "Run with --debug for more information." . PHP_EOL);
}
exit(1);
}