-
-
Notifications
You must be signed in to change notification settings - Fork 963
add functionality to allow hiding commands in /help command #430
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
@@ -69,11 +69,13 @@ public function execute() | |||
); | |||
|
|||
foreach ($command_objs as $command) { | |||
$text .= sprintf( | |||
if($command->getShowInHelp()) { |
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.
Instead of checking for true
and putting all the code into the if
block, it's nicer to test for false
and just continue with the next element.
e.g.
if (!$command->showInHelp()) {
continue;
}
Also, remember to keep your code nice and clean, so make the indentation correct 👍
src/Commands/Command.php
Outdated
* | ||
* @var bool | ||
*/ | ||
protected $showInHelp = true; |
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.
For properties, we prefer snake case, i.e. $show_in_help
👍 for default being true
src/Commands/Command.php
Outdated
* | ||
* @return bool | ||
*/ | ||
public function getShowInHelp() |
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.
Instead of getShowInHelp
, just use showInHelp
. Similar to isEnabled
, it makes it much easier to "read" the code.
Compare:
$command->getShowInHelp();
to
$command->showInHelp();
See what I mean? 😃
Thanks for the awesome review =) |
@@ -69,11 +69,16 @@ public function execute() | |||
); | |||
|
|||
foreach ($command_objs as $command) { | |||
if($command->showInHelp()) { |
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.
Not sure you tested this one, give it a go and see if this does what you want... 😉
Also, there should be a space after the if
like so: if (...)
$text .= sprintf( | ||
'/%s - %s' . PHP_EOL, |
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.
The indentation was correct, so please revert this part.
src/Commands/Command.php
Outdated
@@ -252,6 +259,16 @@ public function getName() | |||
return $this->name; | |||
} | |||
|
|||
/* |
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.
This needs to be /**
for docblock to pick it up correctly.
Also, check the number of spaces and compare it with the others.
e.g.:
/**
* There is an extra space before the *s on these lines!
*/
src/Commands/Command.php
Outdated
*/ | ||
public function showInHelp() | ||
{ | ||
return $this->show_in_help; |
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.
Indent by 4 spaces, always.
What editor do you use? Make sure it has an editorconfig plugin installed.
@lichtscheu Also, notice that the build failed. When you click the Also, your changes will need some new tests, but I'll do those an PR to your branch so that you can see how they're done. If you feel like trying yourself, feel free to do so! |
Add tests for commands shown in help command.
add
protected $showInHelp
var toCommand.php
add
public function getShowInHelp()
toCommand.php
add
if($command->getShowInHelp()) {}
to wrap single command output atHelpCommand.php
with
protected $showInHelp = false;
insert into the command,it is not listed with /help command.I find this very useful, cause i have some commands i only use over cronjob and don't want this commands to show up at the help command.