summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
Diffstat (limited to 'it.class')
-rw-r--r--it.class7
1 files changed, 5 insertions, 2 deletions
diff --git a/it.class b/it.class
index 18f9ffc..1fb95cc 100644
--- a/it.class
+++ b/it.class
@@ -655,7 +655,7 @@ static function imageconvert($p)
* -x EXTENSION Ignore EXTENSION
* Mandatory arguments from the Usage: line are returned under their (lowercased!) name.
* All non-option arguments are returned in 'args'
- * Option text must be indented; if long and short option present, value is stored in long option
+ * Option text must be indented; if long and short option present, value is stored in long one. Defaults in [ ] at end of line
* Options without arguments store true or false under their key
* Options -h and --help will be handled internally by printing usage and exiting
* When printing, the usage will be de-indented so the first line starts in the first column
@@ -690,6 +690,9 @@ static function getopt($helplines)
list($shortoptname, $shortoptarg) = $matches;
}
+ if (($longoptarg || $shortoptarg) && ($default = it::match('\[(.*)\]\s*$', $helpline)))
+ $defaults[$longoptname ? $longoptname : $shortoptname] = it::replace(array('^default:?\s*' => ""), trim($default));
+
if ($longoptname || $shortoptname)
{
if ($longoptname && ($shortoptname || $shortoptname === "0"))
@@ -767,7 +770,7 @@ static function getopt($helplines)
if ($result['verbose'])
$GLOBALS['debug_verbose']++;
- return $result;
+ return $result + (array)$defaults;
}
static function _stdin_next()