4 Commits

Author SHA1 Message Date
ec60970b5d Added getContext method to shell 2017-01-28 13:00:26 +01:00
7c76928c3b Even more tweaks 2017-01-27 04:43:44 +01:00
ff9845e23e Tweaks to help styling 2017-01-27 04:36:23 +01:00
e5b328b822 Spiced up the help 2017-01-27 04:30:50 +01:00

View File

@ -90,6 +90,16 @@ class Shell
} }
} }
/**
* Return the current context
*
* @return Context The current context
*/
public function getContext()
{
return $this->context;
}
/** /**
* Push a new primary context, saving the previous contexts on a stack. * Push a new primary context, saving the previous contexts on a stack.
* *
@ -407,19 +417,27 @@ class Shell
} }
} }
ksort($ghelp); ksort($ghelp);
printf("Commands in current context:\n"); $_ = function($command,$args,$info) {
printf(" \e[96m%s\e[0m \e[0;3m%s\e[0m \e[30G\e[36m%s\e[0m\n", $command, $args, $info);
};
printf("\e[1mCommands:\e[0m\n");
foreach ($help as $command=>$info) { foreach ($help as $command=>$info) {
printf(" %-20s %s\n", $command, $info); if (strpos($command," ")!==false) {
list($command,$args) = explode(" ",$command,2);
} else $args=null;
$_($command, $args,$info);
} }
if (count($ghelp)) { if (count($ghelp)) {
printf("\nImported from parent contexts:\n"); printf("\e[1mCommands from parent contexts:\e[0m\n");
foreach ($ghelp as $command=>$info) { if (strpos($command," ")!==false) {
printf(" %-20s %s\n", $command, $info); list($command,$args) = explode(" ",$command,2);
} } else $args=null;
$_($command, $args,$info);
} }
printf("\nGlobal commands:\n"); printf("\e[1mGlobal commands:\e[0m\n");
printf(" %-20s %s\n", "exit", "Leave the shell"); $_("exit", null, "Leave the shell");
printf(" %-20s %s\n", "..", "Discard the current context and go to parent"); $_(".", null, "Show the context tree");
$_("..", null, "Discard the current context and go to parent");
break; break;
case 'exit': case 'exit':
$this->stop(); $this->stop();