-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Hide commands from ApplicationDescriptor, but allow invoking #20029
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -34,6 +34,7 @@ class Command | |||
private $processTitle; | |||
private $aliases = array(); | |||
private $definition; | |||
private $hidden; |
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.
Should be $this->hidden = false;
* | ||
* @return Command The current instance | ||
*/ | ||
public function setHidden($hiddenBool) |
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.
Should be $hidden
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.
indeed. Thank you sir
@@ -447,6 +448,30 @@ public function getName() | |||
} | |||
|
|||
/** | |||
* Sets if the command should be hidden from application inspection. | |||
* | |||
* @param bool $hiddenBool To show this command or not |
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.
Derp.
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.
What about To hide the command in application descriptions
.
What about other descriptors ? |
@ogizanagi all formats use |
Could we change the method names to follow the same notation as for services? Instead of |
Maybe if we run a private command it should give you a heads up in verbose mode.. would that be useful? |
Good idea. Should we merge this first then address that? Or I can throw it into this PR |
@jwdeitch : Could you update the test suite ( |
@@ -447,6 +448,30 @@ public function getName() | |||
} | |||
|
|||
/** | |||
* To hide the command in application descriptions. | |||
* | |||
* @param bool $public To show this command or not |
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.
I'd suggest something like: Whether the command should be publicly shown or not.
and remove the above description (which brings nothing more IMHO).
/** | ||
* Returns if the command is public in application descriptions. | ||
* | ||
* @return bool If the command is public or not |
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.
Same. I feel this repetition is useless.
*/ | ||
public function setPublic($public) | ||
{ | ||
$this->public = $public; |
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.
should be $this->public = (bool) $public;
* | ||
* @return Command The current instance | ||
*/ | ||
public function setPublic($public) |
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.
What about setPrivate()
without an argument? I don't see a need to switch from private to public.
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.
I suggested changing it to setPublic(false)
to mimic Symfony services ... where you must set public: false
for private services. If we use opposing techniques to do the same (public: false
for services, private: true
for commands) we're increasing the learning curve.
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.
we could meet in the middle at setPublicity
as it's not favoring one way or another :)
Thank you @jwdeitch. |
…voking (jwdeitch, Jordan Deitch) This PR was merged into the 3.2-dev branch. Discussion ---------- Hide commands from ApplicationDescriptor, but allow invoking I would like to hide commands from cluttering the descriptors, but still allow their invocation from code or cron. | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | comma-separated list of tickets fixed by the PR, if any | License | MIT | Doc PR | reference to the documentation PR, if any Commits ------- 746dab3 casting setPublic() arg to bool 0a3c290 update docblocks and added test 6d87837 Update ApplicationDescription.php e969581 update hidden to public 3efa874 Update Command.php dfc1ac8 Update Command.php cd77139 Update Command.php 56a8b93 Update Command.php fb1f30c Update Command.php 1993196 Update Command.php 1add2ad Update Command.php b73f494 Update ApplicationDescription.php 8d0262f Update Command.php b423ab4 Add hidden field
I think calling this private will introduce the same confusion that was just solved with the services: I expect I cannot run private commands outside the app, but I still can. It's simply only hidden in the command listing. Calling this hidden does a better job in describing the feature imo. |
I tend to agree with @wouterj. A private command is indeed not really private in the same sense as for the container, it's just hidden from the list of commands and can still be executed like any other commands. @javiereguiluz WDYT? |
I understand "private" as something hidden, secret, confidential, special. Those are precisely the synonyms of the "private" word. If we talk about commands that cannot be executed outside the app, to me that would be: "banned", "secured", "disabled", "closed", etc. But if this is confusing to others, then "hidden" is also a very understandable name for this feature. |
@javiereguiluz the confusion is that it has a different behavior than
|
…xabbuh) This PR was merged into the 3.2-dev branch. Discussion ---------- [Console] rename Command::private to Command::hidden | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20029 | License | MIT | Doc PR | Commits ------- f900ef0 rename Command::private to Command::hidden
…eguiluz, wouterj) This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #7052). Discussion ---------- Added an article about private console commands This documents symfony/symfony#20029. Commits ------- d1cb043 Reflect private to hidden renaming in the file name 01f474f Reflect renaming from private to hidden 9415643 Added an article about private console commands
I would like to hide commands from cluttering the descriptors, but still allow their invocation from code or cron.