CLI fix for --watch, hide autocomplete documentation
This commit is contained in:
parent
3bb2206753
commit
6096b23a76
|
@ -149,12 +149,12 @@ class Cli extends ApplicationBootstrap
|
|||
$loader = new Loader($this);
|
||||
$loader->parseParams();
|
||||
$screen = Screen::instance();
|
||||
|
||||
while (true) {
|
||||
Benchmark::measure('Watch mode - loop begins');
|
||||
ob_start();
|
||||
echo $screen->clear();
|
||||
$params = clone($this->params);
|
||||
$loader->dispatch();
|
||||
$loader->dispatch($params);
|
||||
Benchmark::measure('Dispatch done');
|
||||
if ($this->showBenchmark) {
|
||||
Benchmark::dump();
|
||||
|
@ -163,7 +163,6 @@ class Cli extends ApplicationBootstrap
|
|||
$out = ob_get_contents();
|
||||
ob_end_clean();
|
||||
echo $screen->clear() . $out;
|
||||
$this->params = $params;
|
||||
sleep($this->watchTimeout);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Icinga\Cli;
|
|||
|
||||
use Icinga\Cli\Screen;
|
||||
use Icinga\Util\Translator;
|
||||
use Icinga\Cli\Params;
|
||||
use Icinga\Application\ApplicationBootstrap as App;
|
||||
use Exception;
|
||||
|
||||
|
@ -38,6 +39,11 @@ abstract class Command
|
|||
}
|
||||
}
|
||||
|
||||
public function setParams(Params $params)
|
||||
{
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function hasRemainingParams()
|
||||
{
|
||||
return $this->params->count() > 0;
|
||||
|
|
|
@ -35,6 +35,7 @@ class Documentation
|
|||
$d = "USAGE: icingaweb [module] <command> [action] [options]\n\n"
|
||||
. "Available commands:\n\n";
|
||||
foreach ($this->loader->listCommands() as $command) {
|
||||
if ($command === 'autocomplete') continue;
|
||||
$obj = $this->loader->getCommandInstance($command);
|
||||
$d .= sprintf(
|
||||
" %-14s %s\n",
|
||||
|
|
|
@ -224,7 +224,7 @@ class Loader
|
|||
$this->dispatch();
|
||||
}
|
||||
|
||||
public function dispatch()
|
||||
public function dispatch(Params $overrideParams = null)
|
||||
{
|
||||
if ($this->commandName === null) {
|
||||
echo $this->docs()->usage($this->moduleName);
|
||||
|
@ -244,6 +244,9 @@ class Loader
|
|||
} else {
|
||||
$obj = $this->getCommandInstance($this->commandName);
|
||||
}
|
||||
if ($overrideParams !== null) {
|
||||
$obj->setParams($overrideParams);
|
||||
}
|
||||
$obj->init();
|
||||
return $obj->{$this->actionName . 'Action'}();
|
||||
} catch (Exception $e) {
|
||||
|
|
Loading…
Reference in New Issue