parent
0002837bd6
commit
454a968f92
@ -1,17 +1,21 @@
|
||||
<?php
|
||||
|
||||
use jrosset\CliProgram\AutoDiscoveryApplication;
|
||||
use jrosset\CliProgram\AutoPrefixApplication;
|
||||
use jrosset\CliProgram\SafeApplication;
|
||||
namespace jrosset\Tests;
|
||||
|
||||
use jrosset\CliProgram\TAutoDiscoveryApplication;
|
||||
use jrosset\CliProgram\AutoDiscoveryDirectory;
|
||||
use jrosset\CliProgram\AutoPrefixNamespaceManager;
|
||||
|
||||
class Application extends \Symfony\Component\Console\Application {
|
||||
use SafeApplication;
|
||||
use AutoDiscoveryApplication;
|
||||
use AutoPrefixApplication;
|
||||
use TAutoDiscoveryApplication;
|
||||
|
||||
public function __construct (string $name = 'UNKNOWN', string $version = 'UNKNOWN') {
|
||||
parent::__construct($name, $version);
|
||||
|
||||
$this->addAutoDiscoverySpots(
|
||||
(new AutoDiscoveryDirectory(__DIR__ . '/Commands'))
|
||||
->addAutoPrefixManagers(new AutoPrefixNamespaceManager('\\jrosset\\Tests\\Commands', 'test'))
|
||||
);
|
||||
$this->addAutoDiscoveredCommands();
|
||||
$this->applyAutoPrefixes();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace jrosset\Tests\Commands;
|
||||
|
||||
use jrosset\CliProgram\BaseCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Hello extends BaseCommand {
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected static $defaultDescription = 'Say hello';
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function __construct () {
|
||||
parent::__construct('hello', 'bonjour');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function execute (InputInterface $input, OutputInterface $output): int {
|
||||
$output->writeln('Hello !');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use jrosset\Tests\Application;
|
||||
|
||||
(new Application())->run();
|
Loading…
Reference in New Issue