aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bin/striplangs.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2017-11-10 14:18:18 +0100
committerAndreas Gohr <andi@splitbrain.org>2017-11-10 14:22:02 +0100
commitcbeaa4a0479ce7023201d4032978899ffaceb187 (patch)
tree6ac50238214f75fd9f8fa47948863a85b5e7e4f3 /bin/striplangs.php
parent0f8cc87bd3c00da5e455ea3abf06e9893c9b9d70 (diff)
downloaddokuwiki-cbeaa4a0479ce7023201d4032978899ffaceb187.tar.gz
dokuwiki-cbeaa4a0479ce7023201d4032978899ffaceb187.zip
replace Doku_CLI with splitbrain\phpcli\CLI
It has few more features (like turning down verbosity) and looks nicer
Diffstat (limited to 'bin/striplangs.php')
-rwxr-xr-xbin/striplangs.php45
1 files changed, 24 insertions, 21 deletions
diff --git a/bin/striplangs.php b/bin/striplangs.php
index 82d27d462..1800971e5 100755
--- a/bin/striplangs.php
+++ b/bin/striplangs.php
@@ -1,25 +1,28 @@
#!/usr/bin/php
<?php
-if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__).'/../').'/');
-define('NOSESSION', 1);
-require_once(DOKU_INC.'inc/init.php');
+use splitbrain\phpcli\CLI;
+use splitbrain\phpcli\Options;
+
+if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/');
+define('NOSESSION', 1);
+require_once(DOKU_INC . 'inc/init.php');
/**
* Remove unwanted languages from a DokuWiki install
*/
-class StripLangsCLI extends DokuCLI {
+class StripLangsCLI extends CLI {
/**
* Register options and arguments on the given $options object
*
- * @param DokuCLI_Options $options
+ * @param Options $options
* @return void
*/
- protected function setup(DokuCLI_Options $options) {
+ protected function setup(Options $options) {
$options->setHelp(
- 'Remove all languages from the installation, besides the ones specified. English language '.
+ 'Remove all languages from the installation, besides the ones specified. English language ' .
'is never removed!'
);
@@ -41,10 +44,10 @@ class StripLangsCLI extends DokuCLI {
*
* Arguments and options have been parsed when this is run
*
- * @param DokuCLI_Options $options
+ * @param Options $options
* @return void
*/
- protected function main(DokuCLI_Options $options) {
+ protected function main(Options $options) {
if($options->getOpt('keep')) {
$keep = explode(',', $options->getOpt('keep'));
if(!in_array('en', $keep)) $keep[] = 'en';
@@ -56,16 +59,16 @@ class StripLangsCLI extends DokuCLI {
}
// Kill all language directories in /inc/lang and /lib/plugins besides those in $langs array
- $this->stripDirLangs(realpath(dirname(__FILE__).'/../inc/lang'), $keep);
- $this->processExtensions(realpath(dirname(__FILE__).'/../lib/plugins'), $keep);
- $this->processExtensions(realpath(dirname(__FILE__).'/../lib/tpl'), $keep);
+ $this->stripDirLangs(realpath(dirname(__FILE__) . '/../inc/lang'), $keep);
+ $this->processExtensions(realpath(dirname(__FILE__) . '/../lib/plugins'), $keep);
+ $this->processExtensions(realpath(dirname(__FILE__) . '/../lib/tpl'), $keep);
}
/**
* Strip languages from extensions
*
- * @param string $path path to plugin or template dir
- * @param array $keep_langs languages to keep
+ * @param string $path path to plugin or template dir
+ * @param array $keep_langs languages to keep
*/
protected function processExtensions($path, $keep_langs) {
if(is_dir($path)) {
@@ -73,9 +76,9 @@ class StripLangsCLI extends DokuCLI {
foreach($entries as $entry) {
if($entry != "." && $entry != "..") {
- if(is_dir($path.'/'.$entry)) {
+ if(is_dir($path . '/' . $entry)) {
- $plugin_langs = $path.'/'.$entry.'/lang';
+ $plugin_langs = $path . '/' . $entry . '/lang';
if(is_dir($plugin_langs)) {
$this->stripDirLangs($plugin_langs, $keep_langs);
@@ -89,17 +92,17 @@ class StripLangsCLI extends DokuCLI {
/**
* Strip languages from path
*
- * @param string $path path to lang dir
- * @param array $keep_langs languages to keep
+ * @param string $path path to lang dir
+ * @param array $keep_langs languages to keep
*/
protected function stripDirLangs($path, $keep_langs) {
$dir = dir($path);
while(($cur_dir = $dir->read()) !== false) {
- if($cur_dir != '.' and $cur_dir != '..' and is_dir($path.'/'.$cur_dir)) {
+ if($cur_dir != '.' and $cur_dir != '..' and is_dir($path . '/' . $cur_dir)) {
if(!in_array($cur_dir, $keep_langs, true)) {
- io_rmdir($path.'/'.$cur_dir, true);
+ io_rmdir($path . '/' . $cur_dir, true);
}
}
}
@@ -108,4 +111,4 @@ class StripLangsCLI extends DokuCLI {
}
$cli = new StripLangsCLI();
-$cli->run(); \ No newline at end of file
+$cli->run();