function multiargument($flag, $legal_values) { parent::anyargument($flag); if (!$this->set) { return; } $map = array(); foreach ($legal_values as $value) { $map[$value] = true; } if (!isset($map[$this->value])) { usage("{$this->value} is not a valid parameter to --{$flag}!"); exit(1); } }
function multiargument($flag, $legal_values) { parent::anyargument($flag); $map = array(); $default = false; foreach($legal_values as $value) { if (substr($value, 0, 1) == "*") $default = substr($value, 1); $map[$value] = true; } if (!$this->set) { if ($default === false) { usage("value not specified for --{$flag}!"); exit(1); } $this->value = $default; return; } if (!isset($map[$this->value])) { usage("{$this->value} is not a valid parameter to --{$flag}!"); exit(1); } }