task/console

Utilities for working with Symfony's Console component and Task

Installs: 1 811

Dependents: 4

Watchers: 2

Language: PHP

v0.3.1 2014-05-22 11:20 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());
}]);