Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
chalasr merged 1 commit intosymfony:masterfromlyrixx:console-single-command
Jan 9, 2020

Conversation

lyrixx
Copy link
Member

@lyrixxlyrixx commentedDec 4, 2019
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#34293
LicenseMIT
Doc PR

<?phprequire__DIR__.'/vendor/autoload.php';useSymfony\Component\Console\Input\InputArgument;useSymfony\Component\Console\Input\InputInterface;useSymfony\Component\Console\Output\OutputInterface;useSymfony\Component\Console\SingleCommandApplication;(newSingleCommandApplication())    ->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:

class MyCommandextends SingleCommandApplication{publicfunctionexecute(InputInterface$input,OutputInterface$output)    {$output->writeln('hello');return0;    }}newMyCommand();

theofidry, fancyweb, yceruto, azjezz, pmontoya, lyrixx, gmorel, joubertredrat, mcg-web, romainnorberg, and 7 more reacted with thumbs up emojirybakit reacted with confused emoji
@lyrixxlyrixxforce-pushed theconsole-single-command branch from83ba9b0 to516713aCompareDecember 4, 2019 16:58
@lyrixxlyrixx changed the title[Console] Add SingleApplicationCommand to ease creation of Single Command Application[Console] Add SingleCommandApplication to ease creation of Single Command ApplicationDec 4, 2019
@nicolas-grekasnicolas-grekas added this to thenext milestoneDec 4, 2019
Copy link
Member

@fabpotfabpot left a 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.

@rybakit

This comment has been minimized.

@lyrixx

This comment has been minimized.

@rybakit

This comment has been minimized.

@lyrixx

This comment has been minimized.

@chalasr

This comment has been minimized.

@lyrixx

This comment has been minimized.

@nicolas-grekas

This comment has been minimized.

@fabpot

This comment has been minimized.

@chalasr

This comment has been minimized.

@lyrixx

This comment has been minimized.

@chalasr

This comment has been minimized.

@lyrixx

This comment has been minimized.

@lyrixx
Copy link
MemberAuthor

OK, I updated the PR to add therun() command. Hope you like it!

Copy link
Member

@chalasrchalasr left a comment
edited
Loading

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

@yceruto

This comment has been minimized.

@lyrixx
Copy link
MemberAuthor

Failures on appveyor & travis are not related

@lyrixxlyrixxforce-pushed theconsole-single-command branch 2 times, most recently from70c168e tod050196CompareJanuary 8, 2020 11:40
…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();```
@lyrixxlyrixxforce-pushed theconsole-single-command branch fromd050196 to4af513dCompareJanuary 8, 2020 11:40
@chalasr
Copy link
Member

Thank you@lyrixx.

lyrixx reacted with heart emoji

chalasr added a commit that referenced this pull requestJan 9, 2020
…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
@chalasrchalasr merged commit4af513d intosymfony:masterJan 9, 2020
@lyrixxlyrixx deleted the console-single-command branchJanuary 9, 2020 07:34
@nicolas-grekasnicolas-grekas modified the milestones:next,5.1May 4, 2020
@fabpotfabpot mentioned this pull requestMay 5, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ycerutoycerutoyceruto left review comments

@azjezzazjezzazjezz left review comments

@fabpotfabpotfabpot requested changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
5.1
Development

Successfully merging this pull request may close these issues.

[Console] Ease creation of single command application
8 participants
@lyrixx@rybakit@chalasr@nicolas-grekas@fabpot@yceruto@azjezz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp