[Console] Added the possibility to set a different default command#9776
[Console] Added the possibility to set a different default command#9776dcsg wants to merge 4 commits intosymfony:masterfrom
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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
|
@jakzal thanks for your tip. Now is more simple and works fine. Do you think is ok to be merged? (after squash) |
There was a problem hiding this comment.
true 👍 already modified and squashed!
|
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
|
Looks ok for me 👍 |
|
@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 |
|
@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. |
|
@piotrpasich I'm -1 for adding an option in |
There was a problem hiding this comment.
we don't put spaces around . in Symfony CS.
|
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 |
|
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 |
|
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. |
|
It took time, but here we go, this is in now. Thank you very much @danielcsgomes. |
|
@fabpot my pleasure :) |
…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
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.