Skip to content

[Console] Added the possibility to set a different default command#9776

Closed
dcsg wants to merge 4 commits intosymfony:masterfrom
dcsg:ticket_8058
Closed

[Console] Added the possibility to set a different default command#9776
dcsg wants to merge 4 commits intosymfony:masterfrom
dcsg:ticket_8058

Conversation

@dcsg
Copy link
Copy Markdown
Member

@dcsg dcsg commented Dec 14, 2013

I am not quite sure if this is the best approach to solve the issue but the solution I provide works. Let me know your suggestions to improve it.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #8058
License MIT
Doc PR symfony/symfony-docs#3426

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method does two things:

  • sets a default command
  • adds a command

I'd make it only does what the method name says (set a default command) and make it accept a command name, not a whole command.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakzal I hadn't thought that way, but I do think it will work fine the way you say and in a more simple way. Will test it and if works well will do the changes

@dcsg
Copy link
Copy Markdown
Member Author

dcsg commented Jan 4, 2014

@jakzal thanks for your tip. Now is more simple and works fine. Do you think is ok to be merged? (after squash)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer adds ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true 👍 already modified and squashed!

@dcsg
Copy link
Copy Markdown
Member Author

dcsg commented Jan 4, 2014

Also I do need to create an entry in documentation for the feature. Will take care of that.

* Added new method `setDefaultCommand` and changed the logic in the doRun
method in order to allow it to run by default a Command setted by the user
instead of the `ListCommand`
* Added tests
* Should fix symfony#8058
* Updated CHANGELOG
@dcsg
Copy link
Copy Markdown
Member Author

dcsg commented Jan 7, 2014

@jakzal @fabpot is the implementation ok? Docs are already created as well.

@piotrpasich
Copy link
Copy Markdown

Looks ok for me 👍
On the other hand, is it possible to create some configuration option in config.yml for this feature?

@dcsg
Copy link
Copy Markdown
Member Author

dcsg commented Jan 7, 2014

@piotrpasich that is Framework related. Also I do think for the framework itself could not make so much sense to do that, but if it does IMO it should be a different PR

@piotrpasich
Copy link
Copy Markdown

@danielcsgomes I'm not sure if this should be in second PR, but ok. We can open a new issue to remember about this change.

@fabpot
Copy link
Copy Markdown
Member

fabpot commented Jan 7, 2014

@piotrpasich I'm -1 for adding an option in config.yml. To me, the possibility to change the default command is very specific and probably never a good idea in the full-stack framework itself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't put spaces around . in Symfony CS.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@stof
Copy link
Copy Markdown
Member

stof commented Jan 7, 2014

I see an issue here (something we faced in PhpSpec, where we finally chose to remove the overwrite of the default command for now): the default command cannot get arguments (the first one would be interpreted as a command name), so changing the default command will only be reliable if the custom command does not have arguments

@fabpot
Copy link
Copy Markdown
Member

fabpot commented Jan 7, 2014

@stof That's to be expected as we are talking about a "default" command to be executed when no arguments are passed to the console application. So, this PR is different from #9564, where you might want to create a Console app with only 1 command.

@stof
Copy link
Copy Markdown
Member

stof commented Jan 7, 2014

yeah, I'm just warning that it might cause some issues if pople start expecting the command to work fully when using it as the default one

@wouterj
Copy link
Copy Markdown
Member

wouterj commented Jan 7, 2014

Well, I think @danielcsgomes did a good work at the documentation for this PR. The article clearly has 2 sections: setting the default and creating a one command app. Both explain other ways to do it, so I don't think people will get confused.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set instead of setted

@dcsg
Copy link
Copy Markdown
Member Author

dcsg commented Jan 7, 2014

@stof @fabpot yes that is a limitation. I will add that information to the Documentation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing dot at the end.

@fabpot
Copy link
Copy Markdown
Member

fabpot commented Jan 7, 2014

It took time, but here we go, this is in now. Thank you very much @danielcsgomes.

@fabpot fabpot closed this in c833518 Jan 7, 2014
@dcsg
Copy link
Copy Markdown
Member Author

dcsg commented Jan 7, 2014

@fabpot my pleasure :)

@dcsg dcsg deleted the ticket_8058 branch January 7, 2014 15:25
weaverryan added a commit to symfony/symfony-docs that referenced this pull request Jan 9, 2014
…component (danielcsgomes)

This PR was merged into the master branch.

Discussion
----------

New Feature: Change the Default Command in the Console component

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#9776)
| Applies to    | 2.5+
| Fixed tickets |

I followed the suggestion from @wouterj in IRC on changing the `single_command_tool` and added the documentation for the new feature there.

Commits
-------

c1b2aad Applied suggestions from Ryan
5e97202 Applyed suggestions from @fabpot and @stof
c23f34e Applied some suggestions
012456d Moved `versionadded` to the right section
730985f Updated references to the new document
af9eac4 Changed the code to remove references to Symfony Framework since it's the standalone component
60e2b3e Added the delete document to avoid broken urls and added a notice that the document was moved to another location
11c7174 Added the version number where the setDefaultCommand was introduced
b29ab89 Documented the Change the Default Command in the Console component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants