Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix duplicate bug in printHelp. Add help strings to built-in commands.

  • Loading branch information...
commit a830eed9af26fefbc56ea2dcfd54b30ac0929e46 1 parent 036d654
Alan Pinstein authored
Showing with 8 additions and 1 deletion.
  1. +6 −1 iphp.php
  2. +2 −0  iphp_commands.php
View
7 iphp.php
@@ -58,10 +58,15 @@ public function options()
}
public function printHelp()
{
+ $uniqueArray = array(); // sadly array_unique doesn't work for arrays of objects. this works, but it slower, but hey it's plenty fast.
$pad = 30;
print str_pad('alias(es)', $pad, ' ', STR_PAD_RIGHT) . "<help>\n";
print str_repeat('-', $pad * 3) . "\n";
- foreach (array_unique($this->internalCommands, SORT_REGULAR) as $name => $command) {
+ foreach ($this->internalCommands as $name => $command) {
+ // only show commands once (due to command aliases)
+ if (in_array($command, $uniqueArray)) continue;
+ $uniqueArray[] = $command;
+
$aliases = $command->name();
if (!is_array($aliases))
{
View
2  iphp_commands.php
@@ -17,6 +17,7 @@ function name()
{
return array('help', '?');
}
+ function help() { return 'View a list of all installed commands.'; }
}
class iphp_command_exit extends iphp_command
@@ -29,6 +30,7 @@ function name()
{
return array('exit', 'die', 'bye', 'quit');
}
+ function help() { return 'Quit the shell.'; }
}
class iphp_command_reload extends iphp_command
Please sign in to comment.
Something went wrong with that request. Please try again.