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

View File

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