Commit Graph

2 Commits

Author SHA1 Message Date
Robin Chalas
63407d8201 [Console] Allow disabling auto-exit for single command apps 2020-08-03 17:23:43 +02:00
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