diff options
author | Christian Helbling | 2014-02-21 15:12:25 +0100 |
---|---|---|
committer | Christian Helbling | 2014-02-21 15:12:25 +0100 |
commit | 26600506229b08792da13dcfb1d4cad5a4f6a006 (patch) | |
tree | 55f0947d9b20b3f1cd9bba372d38a29ecbbe577e | |
parent | 698066659774331dadd9cb0c1dab0aba795588b0 (diff) | |
download | itools-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.class | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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) { |