mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-24 22:34:24 +02:00
parent
801a6719b7
commit
7abd1b906b
55
application/clicommands/VersionCommand.php
Normal file
55
application/clicommands/VersionCommand.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2019 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Clicommands;
|
||||||
|
|
||||||
|
use Icinga\Application\Version;
|
||||||
|
use Icinga\Application\Icinga;
|
||||||
|
use Icinga\Cli\Loader;
|
||||||
|
use Icinga\Cli\Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows version of Icinga Web 2, loaded modules and PHP
|
||||||
|
*
|
||||||
|
* The version command shows version numbers for Icinga Web 2, loaded modules and PHP.
|
||||||
|
*
|
||||||
|
* Usage: icingacli --version
|
||||||
|
*/
|
||||||
|
class VersionCommand extends Command
|
||||||
|
{
|
||||||
|
protected $defaultActionName = 'show';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows version of Icinga Web 2, loaded modules and PHP
|
||||||
|
*
|
||||||
|
* The version command shows version numbers for Icinga Web 2, loaded modules and PHP.
|
||||||
|
*
|
||||||
|
* Usage: icingacli --version
|
||||||
|
*/
|
||||||
|
public function showAction()
|
||||||
|
{
|
||||||
|
$getVersion = Version::get();
|
||||||
|
printf("%-12s %-9s \n", 'Icinga Web 2', $getVersion['appVersion']);
|
||||||
|
|
||||||
|
if (isset($getVersion['gitCommitID'])) {
|
||||||
|
printf("%-12s %-9s \n", 'Git Commit', $getVersion['gitCommitID']);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%-12s %-9s \n", 'PHP Version', PHP_VERSION);
|
||||||
|
|
||||||
|
$modules = Icinga::app()->getModuleManager()->loadEnabledModules()->getLoadedModules();
|
||||||
|
|
||||||
|
$maxLength = 0;
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
$length = strlen($module->getName());
|
||||||
|
if ($length > $maxLength) {
|
||||||
|
$maxLength = $length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%-${maxLength}s %-9s \n", 'MODULE', 'VERSION');
|
||||||
|
foreach ($modules as $module) {
|
||||||
|
printf("%-${maxLength}s %-9s \n", $module->getName(), $module->getVersion());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,8 @@
|
|||||||
<dt><?= $this->translate('Git commit') ?></dt>
|
<dt><?= $this->translate('Git commit') ?></dt>
|
||||||
<dd><?= $this->escape($version['gitCommitID']) ?></dd>
|
<dd><?= $this->escape($version['gitCommitID']) ?></dd>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
<dt><?= $this->translate('PHP Version') ?></dt>
|
||||||
|
<dd><?= $this->escape(PHP_VERSION) ?></dd>
|
||||||
<?php if (isset($version['gitCommitDate'])): ?>
|
<?php if (isset($version['gitCommitDate'])): ?>
|
||||||
<dt><?= $this->translate('Git commit date') ?></dt>
|
<dt><?= $this->translate('Git commit date') ?></dt>
|
||||||
<dd><?= $this->escape($version['gitCommitDate']) ?></dd>
|
<dd><?= $this->escape($version['gitCommitDate']) ?></dd>
|
||||||
|
@ -101,6 +101,9 @@ class Cli extends ApplicationBootstrap
|
|||||||
if ($this->params->shift('help')) {
|
if ($this->params->shift('help')) {
|
||||||
$this->params->unshift('help');
|
$this->params->unshift('help');
|
||||||
}
|
}
|
||||||
|
if ($this->params->shift('version')) {
|
||||||
|
$this->params->unshift('version');
|
||||||
|
}
|
||||||
if ($this->params->shift('autocomplete')) {
|
if ($this->params->shift('autocomplete')) {
|
||||||
$this->params->unshift('autocomplete');
|
$this->params->unshift('autocomplete');
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ class Documentation
|
|||||||
. " --help Show help\n"
|
. " --help Show help\n"
|
||||||
. " --benchmark Show benchmark summary\n"
|
. " --benchmark Show benchmark summary\n"
|
||||||
. " --watch [s] Refresh output every <s> seconds (default: 5)\n"
|
. " --watch [s] Refresh output every <s> seconds (default: 5)\n"
|
||||||
|
. " --version Shows version of Icinga Web 2, loaded modules and PHP\n"
|
||||||
;
|
;
|
||||||
$d .= "\nShow help on a specific command : icingacli help <command>"
|
$d .= "\nShow help on a specific command : icingacli help <command>"
|
||||||
. "\nShow help on a specific module : icingacli help <module>"
|
. "\nShow help on a specific module : icingacli help <module>"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user