Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Commit

Permalink
Add pager section (ref #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jubianchi committed May 20, 2014
1 parent 1634e1d commit cdf64bb
Showing 1 changed file with 22 additions and 32 deletions.
54 changes: 22 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ Given you have the following command:
```php
<?php

use Hoathis\SymfonyConsoleBridge\Example\Application;
use Hoathis\SymfonyConsoleBridge\Output\ConsoleOutput;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

$app = new Application();

$app
Expand All @@ -82,8 +76,6 @@ $app
}
})
;

$app->run(new ArgvInput(), new ConsoleOutput());
```

Running:
Expand Down Expand Up @@ -146,13 +138,6 @@ To use those new `OutputFormatterStyle`, use the usual API :
```php
<?php

namespace Hoathis\SymfonyConsoleBridge\Example;

use Hoathis\SymfonyConsoleBridge\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class Application extends BaseApplication
{
protected function configureIO(InputInterface $input, OutputInterface $output)
Expand Down Expand Up @@ -181,11 +166,6 @@ manually load them:
```php
<?php

namespace Hoathis\SymfonyConsoleBridge\Example;

use Hoathis\SymfonyConsoleBridge\Helper;
use Symfony\Component\Console\Application as BaseApplication;

class Application extends BaseApplication
{
protected function getDefaultHelperSet()
Expand Down Expand Up @@ -213,12 +193,6 @@ being bound to an action:
```php
<?php

use Hoathis\SymfonyConsoleBridge\Example\Application;
use Hoathis\SymfonyConsoleBridge\Output\ConsoleOutput;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

$app = new Application();

$app
Expand Down Expand Up @@ -256,12 +230,6 @@ being bound to an action:
```php
<?php

use Hoathis\SymfonyConsoleBridge\Example\Application;
use Hoathis\SymfonyConsoleBridge\Output\ConsoleOutput;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

$app = new Application();

$app
Expand Down Expand Up @@ -307,3 +275,25 @@ Many other utility method are available
#### Readline

#### Pager

The pager helper will let you display outputs through a pager so the user can easily read and scroll at his will. The helper
provides two pagers: `less` and `more`. You will have to fedd them using a closure wrapping code producing output:

```php
<?php

$app = new Application();

$app
->register('helper:pager:less')
->setCode(function(InputInterface $input, OutputInterface $output) use($app) {
$pager = $app->getHelperSet()->get('pager');

$pager->less(
$output,
function() {
passthru('cat ' . __DIR__ . '/*.php');
}
);
});
```

0 comments on commit cdf64bb

Please sign in to comment.