Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Console] Add SingleCommandApplication to ease creation of Single Command Application#34819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c985204
to83ba9b0
CompareUh oh!
There was an error while loading.Please reload this page.
83ba9b0
to516713a
Comparesrc/Symfony/Component/Console/Tests/phpt/single_application/version_default_name.phptShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good to me.
src/Symfony/Component/Console/Tests/phpt/single_application/version_name.phptShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Console/Tests/phpt/single_application/version_default_name.phptShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Console/Tests/phpt/single_application/help_name.phpt OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Console/Tests/phpt/single_application/help_name.phpt OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
516713a
to7284543
Compare This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7284543
to0ee2fff
CompareOK, I updated the PR to add the |
chalasr left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good to me.
It might be worth throwing from methods likesetAliases()
which make no sense for such command, but that's for another PR.
Build failures unrelated
This comment has been minimized.
This comment has been minimized.
0ee2fff
to7855fae
CompareFailures on appveyor & travis are not related |
Uh oh!
There was an error while loading.Please reload this page.
70c168e
tod050196
Compare…mand Application```<?phprequire __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();```
d050196
to4af513d
CompareThank you@lyrixx. |
…n of Single Command Application (lyrixx)This PR was merged into the 5.1-dev branch.Discussion----------[Console] Add SingleCommandApplication to ease creation of Single Command Application| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets |Fix#34293| License | MIT| Doc PR |---```php<?phprequire __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) { $output->writeln(sprintf('Hello %s!', $input->getArgument('who'))); }) ->run();```---Note: I tried this too, and it works as expected:```phpclass MyCommand extends SingleCommandApplication{ public function execute(InputInterface $input, OutputInterface $output) { $output->writeln('hello'); return 0; }}new MyCommand();```Commits-------4af513d [Console] Add SingleCommandApplication to ease creation of Single Command Application
Uh oh!
There was an error while loading.Please reload this page.
Note: I tried this too, and it works as expected: