use Some\Application;
use Task\Plugin\Console\ApplicationPlugin;
$project->inject(function ($container) {
$app = new Application;
$container['app'] = new ApplicationPlugin($app)
});
$project->addTask('run', ['app', function ($app) {
$app->command('run')
->setVerbose(true)
->pipe($this->getOutput());
}]);
Add to composer.json
:
...
"require-dev": {
"task/console" "~0.2"
}
...
ApplicationPlugin::command()
returns a CommandRunner
which dynamically builds up command arguments and options with setter methods.
Given the following InputDefinition
:
[
new InputOption('option', 'o', InputOption::VALUE_REQUIRED),
new InputOption('flag', 'f', InputOption::VALUE_NONE),
new InputArgument('arg', InputArgument::REQUIRED)
]
$project->addTask('run', ['app', function ($app) {
$app->command('run')
->setOption('foo')
->setFlag(true)
->setArg('wow')
->pipe($this->getOutput());
}]);