diff options
Diffstat (limited to 'lib/plugins/extension/cli.php')
-rw-r--r-- | lib/plugins/extension/cli.php | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/lib/plugins/extension/cli.php b/lib/plugins/extension/cli.php index 0e1bf83d5..4e6200ba2 100644 --- a/lib/plugins/extension/cli.php +++ b/lib/plugins/extension/cli.php @@ -1,5 +1,8 @@ <?php +use dokuwiki\Extension\CLIPlugin; +use splitbrain\phpcli\Options; +use splitbrain\phpcli\TableFormatter; use splitbrain\phpcli\Colors; /** @@ -10,10 +13,10 @@ use splitbrain\phpcli\Colors; * @license GPL2 * @author Andreas Gohr <andi@splitbrain.org> */ -class cli_plugin_extension extends DokuWiki_CLI_Plugin +class cli_plugin_extension extends CLIPlugin { /** @inheritdoc */ - protected function setup(\splitbrain\phpcli\Options $options) + protected function setup(Options $options) { // general setup $options->setHelp( @@ -42,8 +45,11 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin // install $options->registerCommand('install', 'Install or upgrade extensions'); - $options->registerArgument('extensions...', - 'One or more extensions to install. Either by name or download URL', true, 'install' + $options->registerArgument( + 'extensions...', + 'One or more extensions to install. Either by name or download URL', + true, + 'install' ); // uninstall @@ -57,12 +63,10 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin // disable $options->registerCommand('disable', 'Disable installed extensions'); $options->registerArgument('extensions...', 'One or more extensions to disable', true, 'disable'); - - } /** @inheritdoc */ - protected function main(\splitbrain\phpcli\Options $options) + protected function main(Options $options) { /** @var helper_plugin_extension_repository $repo */ $repo = plugin_load('helper', 'extension_repository'); @@ -145,7 +149,7 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin $ext->setExtension($extname); if (!$ext->isInstalled()) { $this->error(sprintf('Extension %s is not installed', $ext->getID())); - $ok += 1; + ++$ok; continue; } @@ -159,7 +163,7 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin if ($status !== true) { $this->error($status); - $ok += 1; + ++$ok; continue; } else { $this->success(sprintf($this->getLang($msg), $ext->getID())); @@ -185,7 +189,7 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin $ext->setExtension($extname); if (!$ext->isInstalled()) { $this->error(sprintf('Extension %s is not installed', $ext->getID())); - $ok += 1; + ++$ok; continue; } @@ -221,13 +225,13 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin $installed = $ext->installFromURL($extname, true); } catch (Exception $e) { $this->error($e->getMessage()); - $ok += 1; + ++$ok; } } else { $ext->setExtension($extname); if (!$ext->getDownloadURL()) { - $ok += 1; + ++$ok; $this->error( sprintf('Could not find download for %s', $ext->getID()) ); @@ -238,11 +242,11 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin $installed = $ext->installOrUpdate(); } catch (Exception $e) { $this->error($e->getMessage()); - $ok += 1; + ++$ok; } } - foreach ($installed as $name => $info) { + foreach ($installed as $info) { $this->success( sprintf( $this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'), @@ -301,9 +305,8 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin global $plugin_controller; $pluginlist = $plugin_controller->getList('', true); $tpllist = glob(DOKU_INC . 'lib/tpl/*', GLOB_ONLYDIR); - $tpllist = array_map(function ($path) { - return 'template:' . basename($path); - }, $tpllist); + $tpllist = array_map(static fn($path) => 'template:' . basename($path), $tpllist); + $list = array_merge($pluginlist, $tpllist); sort($list); return $list; @@ -321,7 +324,7 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin { /** @var helper_plugin_extension_extension $ext */ $ext = $this->loadHelper('extension_extension'); - $tr = new \splitbrain\phpcli\TableFormatter($this->colors); + $tr = new TableFormatter($this->colors); foreach ($list as $name) { @@ -363,10 +366,10 @@ class cli_plugin_extension extends DokuWiki_CLI_Plugin $status, $date, strip_tags(sprintf( - $this->getLang('extensionby'), - $ext->getDisplayName(), - $this->colors->wrap($ext->getAuthor(), Colors::C_PURPLE)) - ) + $this->getLang('extensionby'), + $ext->getDisplayName(), + $this->colors->wrap($ext->getAuthor(), Colors::C_PURPLE) + )) ], [ $ecolor, |