diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-03-20 20:55:57 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-03-20 20:55:57 +0100 |
commit | b0b7909bdd454e9614f4ffe34f384b0da0ce4585 (patch) | |
tree | 136115bdbe375e52ed91a211b7034d75e0b9fea4 /inc | |
parent | 99c6702358b65e9f98d1799d261b4dcc7b88d414 (diff) | |
download | rpg-b0b7909bdd454e9614f4ffe34f384b0da0ce4585.tar.gz rpg-b0b7909bdd454e9614f4ffe34f384b0da0ce4585.tar.bz2 |
converted some more CLI tools, minor CLI class updates
Diffstat (limited to 'inc')
-rw-r--r-- | inc/cli.php | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/inc/cli.php b/inc/cli.php index 84aad3411..c51d9b7d2 100644 --- a/inc/cli.php +++ b/inc/cli.php @@ -323,7 +323,7 @@ class DokuCLI_Options { * @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 $needsarg does this option require an argument? + * @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 * @throws DokuCLI_Exception */ @@ -465,12 +465,13 @@ class DokuCLI_Options { * * Can only be used after parseOptions() has been run * - * @param $option + * @param string $option + * @param mixed $default what to return if the option was not set * @return mixed */ - public function getOpt($option) { + public function getOpt($option, $default = false) { if(isset($this->options[$option])) return $this->options[$option]; - return false; + return $default; } /** @@ -501,6 +502,8 @@ class DokuCLI_Options { $text .= "\n$command"; } + if($hasopts) $text .= ' <OPTIONS>'; + foreach($this->setup[$command]['args'] as $arg) { if($arg['required']) { $text .= ' <' . $arg['name'] . '>'; @@ -519,17 +522,23 @@ class DokuCLI_Options { } if($hasopts) { - $text .= "\n"; + $text .= "\n OPTIONS\n\n"; foreach($this->setup[$command]['opts'] as $long => $opt) { - $name = "--$long"; - if($opt['short']) $name = '-' . $opt['short'] . ' ' . $name; - if($opt['needsarg']) $name .= ' <arg>'; + $name = ''; + if($opt['short']) { + $name .= '-' . $opt['short']; + if($opt['needsarg']) $name .= ' <'.$opt['needsarg'].'>'; + $name .= ', '; + } + $name .= "--$long"; + if($opt['needsarg']) $name .= ' <'.$opt['needsarg'].'>'; $text .= $this->tableFormat( array(2, 20, 52), array('', $name, $opt['help']) ); + $text .= "\n"; } } |