-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
37 lines (30 loc) · 1.17 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Igorw\Fab\FabOutputFormatterStyle;
require 'vendor/autoload.php';
$app = new Application();
$app
->register('foo')
->setDefinition(array(
new InputArgument('bar', InputArgument::REQUIRED, 'Bar'),
))
->setDescription('Does foo with bar')
->setCode(function (InputInterface $input, OutputInterface $output) {
$bar = $input->getArgument('bar');
$output->writeln(sprintf('This is the foo for <info>%s</info>', $bar));
$output->writeln(sprintf('<comment>%s</comment>', sha1($bar)));
});
$input = new ArgvInput();
$output = new ConsoleOutput();
$output->setFormatter(new OutputFormatter(true, [
'info' => new FabOutputFormatterStyle(),
'comment' => new FabOutputFormatterStyle(),
]));
$app->run($input, $output);