Permalink
Browse files

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

  • Loading branch information...
1 parent 036d654 commit a830eed9af26fefbc56ea2dcfd54b30ac0929e46 Alan Pinstein committed Dec 13, 2009
Showing with 8 additions and 1 deletion.
  1. +6 −1 iphp.php
  2. +2 −0 iphp_commands.php
View
@@ -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
@@ -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

0 comments on commit a830eed

Please sign in to comment.