From 26600506229b08792da13dcfb1d4cad5a4f6a006 Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Fri, 21 Feb 2014 15:12:25 +0100 Subject: warn when trying to use defaults on boolean options in it::getopt --- it.class | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'it.class') 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) { -- cgit v1.2.3