Simplified help command, also does autocompletion right now

This commit is contained in:
Thomas Gelf 2013-10-22 13:53:12 +00:00
parent 88223acc47
commit 724a57e93a
1 changed files with 8 additions and 26 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Clicommands;
use Icinga\Cli\Command;
use Icinga\Cli\Loader;
use Icinga\Cli\Documentation;
/**
@ -30,31 +31,12 @@ class HelpCommand extends Command
$module = null;
$command = null;
$action = null;
$loader = $this->app->cliLoader();
$command = $this->params->shift();
if ($loader->hasCommand($command)) {
$action = $this->params->shift();
if (! $loader->getCommandInstance($command)->hasActionName($action)) {
$action = null;
}
} else {
if ($loader->hasModule($command)) {
$module = $command;
$command = $this->params->shift();
if ($loader->hasModuleCommand($module, $command)) {
$action = $this->params->shift();
$mod = $loader->getModuleCommandInstance($module, $command);
if (! $mod->hasActionName($action)) {
$action = null;
}
} else {
$command = null;
}
} else {
$command = null;
}
}
echo $this->docs()->usage($module, $command, $action);
$loader = new Loader($this->app);
$loader->parseParams();
echo $this->docs()->usage(
$loader->getModuleName(),
$loader->getCommandName(),
$loader->getActionName()
);
}
}