mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-17 19:23:27 +02:00
Revised Commands -> use symfony/console -> php ma (MyAAC)
Usage: php ma list php ma cache:clear php ma plugin:install guild-wars.zip More sophisticated: echo "Hello, this is hello world message" | php ma mail:send test@test.com --subject "This is subject" Also: custom commands can be added via Plugins: just need to return new class instance that extends \MyAAC\Commands\Command in plugins/*/commands folder
This commit is contained in:
37
ma
Normal file
37
ma
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/common.php';
|
||||
|
||||
if(!IS_CLI) {
|
||||
echo 'This script can be run only in command line mode.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once SYSTEM . 'functions.php';
|
||||
require_once SYSTEM . 'init.php';
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
$application = new Application();
|
||||
|
||||
$commandsGlob = glob(SYSTEM . 'src/Commands/*.php');
|
||||
foreach ($commandsGlob as $item) {
|
||||
$name = pathinfo($item, PATHINFO_FILENAME);
|
||||
if ($name == 'Command') { // ignore base Command class
|
||||
continue;
|
||||
}
|
||||
|
||||
$commandPre = '\\MyAAC\Commands\\';
|
||||
$application->add(new ($commandPre . $name));
|
||||
}
|
||||
|
||||
$pluginCommands = glob(PLUGINS . '*/commands/*.php');
|
||||
foreach ($pluginCommands as $item) {
|
||||
$application->add(require $item);
|
||||
}
|
||||
|
||||
$application->setName('MyAAC');
|
||||
$application->setVersion(MYAAC_VERSION);
|
||||
|
||||
$application->run();
|
Reference in New Issue
Block a user