From 7abd1b906b3d10339378cf80f610efdde2ce7c6f Mon Sep 17 00:00:00 2001 From: Niko Martini Date: Tue, 25 Jun 2019 15:40:55 +0200 Subject: [PATCH] Cli: add version command refs #3763 --- application/clicommands/VersionCommand.php | 55 +++++++++++++++++++++ application/views/scripts/about/index.phtml | 2 + library/Icinga/Application/Cli.php | 3 ++ library/Icinga/Cli/Documentation.php | 1 + 4 files changed, 61 insertions(+) create mode 100644 application/clicommands/VersionCommand.php diff --git a/application/clicommands/VersionCommand.php b/application/clicommands/VersionCommand.php new file mode 100644 index 000000000..13c62dddb --- /dev/null +++ b/application/clicommands/VersionCommand.php @@ -0,0 +1,55 @@ +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()); + } + } +} diff --git a/application/views/scripts/about/index.phtml b/application/views/scripts/about/index.phtml index e23740238..d2237d996 100644 --- a/application/views/scripts/about/index.phtml +++ b/application/views/scripts/about/index.phtml @@ -12,6 +12,8 @@
translate('Git commit') ?>
escape($version['gitCommitID']) ?>
+
translate('PHP Version') ?>
+
escape(PHP_VERSION) ?>
translate('Git commit date') ?>
escape($version['gitCommitDate']) ?>
diff --git a/library/Icinga/Application/Cli.php b/library/Icinga/Application/Cli.php index eeba18ec1..243771919 100644 --- a/library/Icinga/Application/Cli.php +++ b/library/Icinga/Application/Cli.php @@ -101,6 +101,9 @@ class Cli extends ApplicationBootstrap if ($this->params->shift('help')) { $this->params->unshift('help'); } + if ($this->params->shift('version')) { + $this->params->unshift('version'); + } if ($this->params->shift('autocomplete')) { $this->params->unshift('autocomplete'); } diff --git a/library/Icinga/Cli/Documentation.php b/library/Icinga/Cli/Documentation.php index 474b74f9c..111745efa 100644 --- a/library/Icinga/Cli/Documentation.php +++ b/library/Icinga/Cli/Documentation.php @@ -57,6 +57,7 @@ class Documentation . " --help Show help\n" . " --benchmark Show benchmark summary\n" . " --watch [s] Refresh output every 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 " . "\nShow help on a specific module : icingacli help "