task/console

Utilities for working with Symfony's Console component and Task

v0.4.0 2015-09-08 12:36 UTC

This package is not auto-updated.

Last update: 2024-12-21 17:27:39 UTC


README

Build Status Coverage Status

Example

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());
}]);

Installation

Add to composer.json:

...
"require-dev": {
    "task/console" "~0.2"
}
...

Usage

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());
}]);