Grégoire Pineau
|
4af513d449
|
[Console] Add SingleCommandApplication to ease creation of Single Command Application
```
<?php
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\SingleCommandApplication;
(new SingleCommandApplication())
->setName('My Super Command') // Optional
->setVersion('1.0.0') // Optional
->setProcessTitle('my_proc_title') // Optional
->addArgument('who', InputArgument::OPTIONAL, 'Who', 'World') // Optional
->setCode(function(InputInterface $input, OutputInterface $output): int {
$output->writeln(sprintf('Hello %s!', $input->getArgument('who')));
return 0;
})
->run()
;
```
|
2020-01-08 12:40:31 +01:00 |
|