summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Helbling2014-02-21 15:12:25 +0100
committerChristian Helbling2014-02-21 15:12:25 +0100
commit26600506229b08792da13dcfb1d4cad5a4f6a006 (patch)
tree55f0947d9b20b3f1cd9bba372d38a29ecbbe577e
parent698066659774331dadd9cb0c1dab0aba795588b0 (diff)
downloaditools-26600506229b08792da13dcfb1d4cad5a4f6a006.tar.gz
itools-26600506229b08792da13dcfb1d4cad5a4f6a006.tar.bz2
itools-26600506229b08792da13dcfb1d4cad5a4f6a006.zip
warn when trying to use defaults on boolean options in it::getopt
-rw-r--r--it.class9
1 files changed, 7 insertions, 2 deletions
diff --git a/it.class b/it.class
index 91c10c1..7f2dc1e 100644
--- a/it.class
+++ b/it.class
@@ -739,8 +739,13 @@ static function getopt($helplines, $p = array())
list($shortoptname, $shortoptarg) = $matches;
}
- if (($longoptarg || $shortoptarg) && ($default = it::match('\[(.*)\]\s*$', $helpline)))
- $defaults[$longoptname ? $longoptname : $shortoptname] = it::replace(array('^default:?\s*' => ""), trim($default));
+ if ($default = it::match('\[(.*)\]\s*$', $helpline))
+ {
+ if ($longoptarg || $shortoptarg)
+ $defaults[$longoptname ? $longoptname : $shortoptname] = it::replace(array('^default:?\s*' => ""), trim($default));
+ else if (($longoptname || $shortoptname) && it::match('^\w+$', $default))
+ it::error('defaults for boolean arguments not supported!');
+ }
if ($longoptname || $shortoptname)
{