code reformat
This commit is contained in:
parent
e82b082ef3
commit
1c36b3d86f
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/');
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__).'/../').'/');
|
||||
define('NOSESSION', 1);
|
||||
require_once(DOKU_INC . 'inc/init.php');
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
|
||||
/**
|
||||
* Easily manage DokuWiki git repositories
|
||||
|
@ -19,51 +19,51 @@ class GitToolCLI extends DokuCLI {
|
|||
*/
|
||||
protected function setup(DokuCLI_Options $options) {
|
||||
$options->setHelp(
|
||||
"Manage git repositories for DokuWiki and its plugins and templates.\n\n" .
|
||||
"$> ./bin/gittool.php clone gallery template:ach\n" .
|
||||
"$> ./bin/gittool.php repos\n" .
|
||||
"$> ./bin/gittool.php origin -v"
|
||||
"Manage git repositories for DokuWiki and its plugins and templates.\n\n".
|
||||
"$> ./bin/gittool.php clone gallery template:ach\n".
|
||||
"$> ./bin/gittool.php repos\n".
|
||||
"$> ./bin/gittool.php origin -v"
|
||||
);
|
||||
|
||||
$options->registerArgument(
|
||||
'command',
|
||||
'Command to execute. See below',
|
||||
true
|
||||
'command',
|
||||
'Command to execute. See below',
|
||||
true
|
||||
);
|
||||
|
||||
$options->registerCommand(
|
||||
'clone',
|
||||
'Tries to install a known plugin or template (prefix with template:) via git. Uses the DokuWiki.org ' .
|
||||
'plugin repository to find the proper git repository. Multiple extensions can be given as parameters'
|
||||
'clone',
|
||||
'Tries to install a known plugin or template (prefix with template:) via git. Uses the DokuWiki.org '.
|
||||
'plugin repository to find the proper git repository. Multiple extensions can be given as parameters'
|
||||
);
|
||||
$options->registerArgument(
|
||||
'extension',
|
||||
'name of the extension to install, prefix with \'template:\' for templates',
|
||||
true,
|
||||
'clone'
|
||||
'extension',
|
||||
'name of the extension to install, prefix with \'template:\' for templates',
|
||||
true,
|
||||
'clone'
|
||||
);
|
||||
|
||||
$options->registerCommand(
|
||||
'install',
|
||||
'The same as clone, but when no git source repository can be found, the extension is installed via ' .
|
||||
'download'
|
||||
'install',
|
||||
'The same as clone, but when no git source repository can be found, the extension is installed via '.
|
||||
'download'
|
||||
);
|
||||
$options->registerArgument(
|
||||
'extension',
|
||||
'name of the extension to install, prefix with \'template:\' for templates',
|
||||
true,
|
||||
'install'
|
||||
'extension',
|
||||
'name of the extension to install, prefix with \'template:\' for templates',
|
||||
true,
|
||||
'install'
|
||||
);
|
||||
|
||||
$options->registerCommand(
|
||||
'repos',
|
||||
'Lists all git repositories found in this DokuWiki installation'
|
||||
'repos',
|
||||
'Lists all git repositories found in this DokuWiki installation'
|
||||
);
|
||||
|
||||
$options->registerCommand(
|
||||
'*',
|
||||
'Any unknown commands are assumed to be arguments to git and will be executed in all repositories ' .
|
||||
'found within this DokuWiki installation'
|
||||
'*',
|
||||
'Any unknown commands are assumed to be arguments to git and will be executed in all repositories '.
|
||||
'found within this DokuWiki installation'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class GitToolCLI extends DokuCLI {
|
|||
|
||||
switch($command) {
|
||||
case '':
|
||||
echo $options->help('foo');
|
||||
echo $options->help();
|
||||
break;
|
||||
case 'clone':
|
||||
$this->cmd_clone($options->args);
|
||||
|
@ -123,8 +123,8 @@ class GitToolCLI extends DokuCLI {
|
|||
}
|
||||
|
||||
echo "\n";
|
||||
if($succeeded) $this->success('successfully cloned the following extensions: ' . join(', ', $succeeded));
|
||||
if($errors) $this->error('failed to clone the following extensions: ' . join(', ', $errors));
|
||||
if($succeeded) $this->success('successfully cloned the following extensions: '.join(', ', $succeeded));
|
||||
if($errors) $this->error('failed to clone the following extensions: '.join(', ', $errors));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,8 +156,8 @@ class GitToolCLI extends DokuCLI {
|
|||
}
|
||||
|
||||
echo "\n";
|
||||
if($succeeded) $this->success('successfully installed the following extensions: ' . join(', ', $succeeded));
|
||||
if($errors) $this->error('failed to install the following extensions: ' . join(', ', $errors));
|
||||
if($succeeded) $this->success('successfully installed the following extensions: '.join(', ', $succeeded));
|
||||
if($errors) $this->error('failed to install the following extensions: '.join(', ', $errors));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,9 +246,9 @@ class GitToolCLI extends DokuCLI {
|
|||
*/
|
||||
private function cloneExtension($ext, $repo) {
|
||||
if(substr($ext, 0, 9) == 'template:') {
|
||||
$target = fullpath(tpl_incdir() . '../' . substr($ext, 9));
|
||||
$target = fullpath(tpl_incdir().'../'.substr($ext, 9));
|
||||
} else {
|
||||
$target = DOKU_PLUGIN . $ext;
|
||||
$target = DOKU_PLUGIN.$ext;
|
||||
}
|
||||
|
||||
$this->info("cloning $ext from $repo to $target");
|
||||
|
@ -273,15 +273,15 @@ class GitToolCLI extends DokuCLI {
|
|||
private function findRepos() {
|
||||
$this->info('Looking for .git directories');
|
||||
$data = array_merge(
|
||||
glob(DOKU_INC . '.git', GLOB_ONLYDIR),
|
||||
glob(DOKU_PLUGIN . '*/.git', GLOB_ONLYDIR),
|
||||
glob(fullpath(tpl_incdir() . '../') . '/*/.git', GLOB_ONLYDIR)
|
||||
glob(DOKU_INC.'.git', GLOB_ONLYDIR),
|
||||
glob(DOKU_PLUGIN.'*/.git', GLOB_ONLYDIR),
|
||||
glob(fullpath(tpl_incdir().'../').'/*/.git', GLOB_ONLYDIR)
|
||||
);
|
||||
|
||||
if(!$data) {
|
||||
$this->error('Found no .git directories');
|
||||
} else {
|
||||
$this->success('Found ' . count($data) . ' .git directories');
|
||||
$this->success('Found '.count($data).' .git directories');
|
||||
}
|
||||
$data = array_map('fullpath', array_map('dirname', $data));
|
||||
return $data;
|
||||
|
@ -306,7 +306,7 @@ class GitToolCLI extends DokuCLI {
|
|||
if(preg_match('/github\.com\/([^\/]+)\/([^\/]+)/i', $repourl, $m)) {
|
||||
$user = $m[1];
|
||||
$repo = $m[2];
|
||||
return 'https://github.com/' . $user . '/' . $repo . '.git';
|
||||
return 'https://github.com/'.$user.'/'.$repo.'.git';
|
||||
}
|
||||
|
||||
// match gitorious repos
|
||||
|
@ -315,14 +315,14 @@ class GitToolCLI extends DokuCLI {
|
|||
$repo = $m[2];
|
||||
if(!$repo) $repo = $user;
|
||||
|
||||
return 'https://git.gitorious.org/' . $user . '/' . $repo . '.git';
|
||||
return 'https://git.gitorious.org/'.$user.'/'.$repo.'.git';
|
||||
}
|
||||
|
||||
// match bitbucket repos - most people seem to use mercurial there though
|
||||
if(preg_match('/bitbucket\.org\/([^\/]+)\/([^\/]+)/i', $repourl, $m)) {
|
||||
$user = $m[1];
|
||||
$repo = $m[2];
|
||||
return 'https://bitbucket.org/' . $user . '/' . $repo . '.git';
|
||||
return 'https://bitbucket.org/'.$user.'/'.$repo.'.git';
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/');
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__).'/../').'/');
|
||||
define('NOSESSION', 1);
|
||||
require_once(DOKU_INC . 'inc/init.php');
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
|
||||
/**
|
||||
* Update the Search Index from command line
|
||||
*/
|
||||
class IndexerCLI extends DokuCLI {
|
||||
|
||||
private $quiet = false;
|
||||
|
@ -17,19 +20,19 @@ class IndexerCLI extends DokuCLI {
|
|||
*/
|
||||
protected function setup(DokuCLI_Options $options) {
|
||||
$options->setHelp(
|
||||
'Updates the searchindex by indexing all new or changed pages. When the -c option is ' .
|
||||
'given the index is cleared first.'
|
||||
'Updates the searchindex by indexing all new or changed pages. When the -c option is '.
|
||||
'given the index is cleared first.'
|
||||
);
|
||||
|
||||
$options->registerOption(
|
||||
'clear',
|
||||
'clear the index before updating',
|
||||
'c'
|
||||
'clear',
|
||||
'clear the index before updating',
|
||||
'c'
|
||||
);
|
||||
$options->registerOption(
|
||||
'quiet',
|
||||
'don\'t produce any output',
|
||||
'q'
|
||||
'quiet',
|
||||
'don\'t produce any output',
|
||||
'q'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,7 +61,7 @@ class IndexerCLI extends DokuCLI {
|
|||
$data = array();
|
||||
$this->quietecho("Searching pages... ");
|
||||
search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true));
|
||||
$this->quietecho(count($data) . " pages found.\n");
|
||||
$this->quietecho(count($data)." pages found.\n");
|
||||
|
||||
foreach($data as $val) {
|
||||
$this->index($val['id']);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/');
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__).'/../').'/');
|
||||
define('NOSESSION', 1);
|
||||
require_once(DOKU_INC . 'inc/init.php');
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ require_once(DOKU_INC . 'inc/init.php');
|
|||
* DokuWiki markup
|
||||
*
|
||||
* @license GPL2
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
class RenderCLI extends DokuCLI {
|
||||
|
||||
|
@ -26,11 +26,11 @@ class RenderCLI extends DokuCLI {
|
|||
*/
|
||||
protected function setup(DokuCLI_Options $options) {
|
||||
$options->setHelp(
|
||||
'A simple commandline tool to render some DokuWiki syntax with a given renderer.' .
|
||||
"\n\n" .
|
||||
'This may not work for plugins that expect a certain environment to be ' .
|
||||
'set up before rendering, but should work for most or even all standard ' .
|
||||
'DokuWiki markup'
|
||||
'A simple commandline tool to render some DokuWiki syntax with a given renderer.'.
|
||||
"\n\n".
|
||||
'This may not work for plugins that expect a certain environment to be '.
|
||||
'set up before rendering, but should work for most or even all standard '.
|
||||
'DokuWiki markup'
|
||||
);
|
||||
$options->registerOption('renderer', 'The renderer mode to use. Defaults to xhtml', 'r', 'mode');
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class RenderCLI extends DokuCLI {
|
|||
|
||||
// do the action
|
||||
$source = stream_get_contents(STDIN);
|
||||
$info = array();
|
||||
$info = array();
|
||||
$result = p_render($renderer, p_get_instructions($source), $info);
|
||||
if(is_null($result)) throw new DokuCLI_Exception("No such renderer $renderer");
|
||||
echo $result;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/');
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__).'/../').'/');
|
||||
define('NOSESSION', 1);
|
||||
require_once(DOKU_INC . 'inc/init.php');
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
|
||||
|
||||
/**
|
||||
* Remove unwanted languages from a DokuWiki install
|
||||
*/
|
||||
class StripLangsCLI extends DokuCLI {
|
||||
|
||||
/**
|
||||
|
@ -16,19 +19,19 @@ class StripLangsCLI extends DokuCLI {
|
|||
protected function setup(DokuCLI_Options $options) {
|
||||
|
||||
$options->setHelp(
|
||||
'Remove all languages from the installation, besides the ones specified. English language ' .
|
||||
'is never removed!'
|
||||
'Remove all languages from the installation, besides the ones specified. English language '.
|
||||
'is never removed!'
|
||||
);
|
||||
|
||||
$options->registerOption(
|
||||
'keep',
|
||||
'Comma separated list of languages to keep in addition to English.',
|
||||
'k'
|
||||
'keep',
|
||||
'Comma separated list of languages to keep in addition to English.',
|
||||
'k'
|
||||
);
|
||||
$options->registerOption(
|
||||
'english-only',
|
||||
'Remove all languages except English',
|
||||
'e'
|
||||
'english-only',
|
||||
'Remove all languages except English',
|
||||
'e'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -52,16 +55,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)) {
|
||||
|
@ -69,9 +72,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);
|
||||
|
@ -85,17 +88,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/');
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__).'/../').'/');
|
||||
define('NOSESSION', 1);
|
||||
require_once(DOKU_INC . 'inc/init.php');
|
||||
require_once(DOKU_INC.'inc/init.php');
|
||||
|
||||
/**
|
||||
* Find wanted pages
|
||||
*/
|
||||
class WantedPagesCLI extends DokuCLI {
|
||||
|
||||
const DIR_CONTINUE = 1;
|
||||
|
@ -18,12 +21,12 @@ class WantedPagesCLI extends DokuCLI {
|
|||
*/
|
||||
protected function setup(DokuCLI_Options $options) {
|
||||
$options->setHelp(
|
||||
'Outputs a list of wanted pages (pages which have internal links but do not yet exist).'
|
||||
'Outputs a list of wanted pages (pages which have internal links but do not yet exist).'
|
||||
);
|
||||
$options->registerArgument(
|
||||
'namespace',
|
||||
'The namespace to lookup. Defaults to root namespace',
|
||||
false
|
||||
'namespace',
|
||||
'The namespace to lookup. Defaults to root namespace',
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -38,7 +41,7 @@ class WantedPagesCLI extends DokuCLI {
|
|||
protected function main(DokuCLI_Options $options) {
|
||||
|
||||
if($options->args) {
|
||||
$startdir = dirname(wikiFN($options->args[0] . ':xxx'));
|
||||
$startdir = dirname(wikiFN($options->args[0].':xxx'));
|
||||
} else {
|
||||
$startdir = dirname(wikiFN('xxx'));
|
||||
}
|
||||
|
@ -54,7 +57,7 @@ class WantedPagesCLI extends DokuCLI {
|
|||
sort($wanted_pages);
|
||||
|
||||
foreach($wanted_pages as $page) {
|
||||
print $page . "\n";
|
||||
print $page."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +65,7 @@ class WantedPagesCLI extends DokuCLI {
|
|||
if($entry == '.' || $entry == '..') {
|
||||
return WantedPagesCLI::DIR_CONTINUE;
|
||||
}
|
||||
if(is_dir($basepath . '/' . $entry)) {
|
||||
if(is_dir($basepath.'/'.$entry)) {
|
||||
if(strpos($entry, '_') === 0) {
|
||||
return WantedPagesCLI::DIR_CONTINUE;
|
||||
}
|
||||
|
@ -78,7 +81,7 @@ class WantedPagesCLI extends DokuCLI {
|
|||
static $trunclen = null;
|
||||
if(!$trunclen) {
|
||||
global $conf;
|
||||
$trunclen = strlen($conf['datadir'] . ':');
|
||||
$trunclen = strlen($conf['datadir'].':');
|
||||
}
|
||||
|
||||
if(!is_dir($dir)) {
|
||||
|
@ -92,11 +95,11 @@ class WantedPagesCLI extends DokuCLI {
|
|||
if($status == WantedPagesCLI::DIR_CONTINUE) {
|
||||
continue;
|
||||
} else if($status == WantedPagesCLI::DIR_NS) {
|
||||
$pages = array_merge($pages, $this->get_pages($dir . '/' . $entry));
|
||||
$pages = array_merge($pages, $this->get_pages($dir.'/'.$entry));
|
||||
} else {
|
||||
$page = array(
|
||||
'id' => pathID(substr($dir . '/' . $entry, $trunclen)),
|
||||
'file' => $dir . '/' . $entry,
|
||||
'id' => pathID(substr($dir.'/'.$entry, $trunclen)),
|
||||
'file' => $dir.'/'.$entry,
|
||||
);
|
||||
$pages[] = $page;
|
||||
}
|
||||
|
|
67
inc/cli.php
67
inc/cli.php
|
@ -57,13 +57,13 @@ abstract class DokuCLI {
|
|||
// setup
|
||||
$this->setup($this->options);
|
||||
$this->options->registerOption(
|
||||
'no-colors',
|
||||
'Do not use any colors in output. Useful when piping output to other tools or files.'
|
||||
'no-colors',
|
||||
'Do not use any colors in output. Useful when piping output to other tools or files.'
|
||||
);
|
||||
$this->options->registerOption(
|
||||
'help',
|
||||
'Display this help screen and exit immeadiately.',
|
||||
'h'
|
||||
'help',
|
||||
'Display this help screen and exit immeadiately.',
|
||||
'h'
|
||||
);
|
||||
|
||||
// parse
|
||||
|
@ -101,7 +101,7 @@ abstract class DokuCLI {
|
|||
}
|
||||
if(!$code) $code = DokuCLI_Exception::E_ANY;
|
||||
|
||||
$this->colors->ptln($error, 'red');
|
||||
$this->error($error);
|
||||
exit($code);
|
||||
}
|
||||
|
||||
|
@ -199,13 +199,13 @@ class DokuCLI_Colors {
|
|||
/**
|
||||
* Convenience function to print a line in a given color
|
||||
*
|
||||
* @param $line
|
||||
* @param $color
|
||||
* @param $line
|
||||
* @param $color
|
||||
* @param resource $channel
|
||||
*/
|
||||
public function ptln($line, $color, $channel=STDOUT) {
|
||||
public function ptln($line, $color, $channel = STDOUT) {
|
||||
$this->set($color);
|
||||
fwrite($channel, rtrim($line) . "\n");
|
||||
fwrite($channel, rtrim($line)."\n");
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
|
@ -253,6 +253,9 @@ class DokuCLI_Options {
|
|||
/** @var string the executed script */
|
||||
protected $bin;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->setup = array(
|
||||
'' => array(
|
||||
|
@ -282,10 +285,10 @@ class DokuCLI_Options {
|
|||
*
|
||||
* This has to be called in the order arguments are expected
|
||||
*
|
||||
* @param string $arg argument name (just for help)
|
||||
* @param string $help help text
|
||||
* @param bool $required is this a required argument
|
||||
* @param string $command if theses apply to a sub command only
|
||||
* @param string $arg argument name (just for help)
|
||||
* @param string $help help text
|
||||
* @param bool $required is this a required argument
|
||||
* @param string $command if theses apply to a sub command only
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function registerArgument($arg, $help, $required = true, $command = '') {
|
||||
|
@ -321,11 +324,11 @@ class DokuCLI_Options {
|
|||
/**
|
||||
* Register an option for option parsing and help generation
|
||||
*
|
||||
* @param string $long multi character option (specified with --)
|
||||
* @param string $help help text for this option
|
||||
* @param string|null $short one character option (specified with -)
|
||||
* @param string $long multi character option (specified with --)
|
||||
* @param string $help help text for this option
|
||||
* @param string|null $short one character option (specified with -)
|
||||
* @param bool|string $needsarg does this option require an argument? give it a name here
|
||||
* @param string $command what command does this option apply to
|
||||
* @param string $command what command does this option apply to
|
||||
* @throws DokuCLI_Exception
|
||||
*/
|
||||
public function registerOption($long, $help, $short = null, $needsarg = false, $command = '') {
|
||||
|
@ -467,7 +470,7 @@ class DokuCLI_Options {
|
|||
* Can only be used after parseOptions() has been run
|
||||
*
|
||||
* @param string $option
|
||||
* @param mixed $default what to return if the option was not set
|
||||
* @param mixed $default what to return if the option was not set
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOpt($option, $default = false) {
|
||||
|
@ -498,7 +501,7 @@ class DokuCLI_Options {
|
|||
$hasargs = (bool) $this->setup[$command]['args'];
|
||||
|
||||
if(!$command) {
|
||||
$text .= 'USAGE: ' . $this->bin;
|
||||
$text .= 'USAGE: '.$this->bin;
|
||||
} else {
|
||||
$text .= "\n$command";
|
||||
}
|
||||
|
@ -507,9 +510,9 @@ class DokuCLI_Options {
|
|||
|
||||
foreach($this->setup[$command]['args'] as $arg) {
|
||||
if($arg['required']) {
|
||||
$text .= ' <' . $arg['name'] . '>';
|
||||
$text .= ' <'.$arg['name'].'>';
|
||||
} else {
|
||||
$text .= ' [<' . $arg['name'] . '>]';
|
||||
$text .= ' [<'.$arg['name'].'>]';
|
||||
}
|
||||
}
|
||||
$text .= "\n";
|
||||
|
@ -517,8 +520,8 @@ class DokuCLI_Options {
|
|||
if($this->setup[$command]['help']) {
|
||||
$text .= "\n";
|
||||
$text .= $this->tableFormat(
|
||||
array(2, 72),
|
||||
array('', $this->setup[$command]['help'] . "\n")
|
||||
array(2, 72),
|
||||
array('', $this->setup[$command]['help']."\n")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -528,7 +531,7 @@ class DokuCLI_Options {
|
|||
|
||||
$name = '';
|
||||
if($opt['short']) {
|
||||
$name .= '-' . $opt['short'];
|
||||
$name .= '-'.$opt['short'];
|
||||
if($opt['needsarg']) $name .= ' <'.$opt['needsarg'].'>';
|
||||
$name .= ', ';
|
||||
}
|
||||
|
@ -536,8 +539,8 @@ class DokuCLI_Options {
|
|||
if($opt['needsarg']) $name .= ' <'.$opt['needsarg'].'>';
|
||||
|
||||
$text .= $this->tableFormat(
|
||||
array(2, 20, 52),
|
||||
array('', $name, $opt['help'])
|
||||
array(2, 20, 52),
|
||||
array('', $name, $opt['help'])
|
||||
);
|
||||
$text .= "\n";
|
||||
}
|
||||
|
@ -546,11 +549,11 @@ class DokuCLI_Options {
|
|||
if($hasargs) {
|
||||
$text .= "\n";
|
||||
foreach($this->setup[$command]['args'] as $arg) {
|
||||
$name = '<' . $arg['name'] . '>';
|
||||
$name = '<'.$arg['name'].'>';
|
||||
|
||||
$text .= $this->tableFormat(
|
||||
array(2, 20, 52),
|
||||
array('', $name, $arg['help'])
|
||||
array(2, 20, 52),
|
||||
array('', $name, $arg['help'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -591,7 +594,7 @@ class DokuCLI_Options {
|
|||
* Displays text in multiple word wrapped columns
|
||||
*
|
||||
* @param array $widths list of column widths (in characters)
|
||||
* @param array $texts list of texts for each column
|
||||
* @param array $texts list of texts for each column
|
||||
* @return string
|
||||
*/
|
||||
private function tableFormat($widths, $texts) {
|
||||
|
@ -613,7 +616,7 @@ class DokuCLI_Options {
|
|||
} else {
|
||||
$val = '';
|
||||
}
|
||||
$out .= sprintf('%-' . $width . 's', $val);
|
||||
$out .= sprintf('%-'.$width.'s', $val);
|
||||
}
|
||||
$out .= "\n";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue