X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fcommandline.inc;h=a475e11d01abba19ba7fb9ba8126f00f312388c7;hb=3062cc270607ad60993e5e6d6e3977fab74508b0;hp=4a7757fb98f13e43c47bf55cdd0841da848304fd;hpb=3e60160f07f32d109b545db6b73be344b9180de8;p=quix0rs-gnu-social.git diff --git a/scripts/commandline.inc b/scripts/commandline.inc index 4a7757fb98..a475e11d01 100644 --- a/scripts/commandline.inc +++ b/scripts/commandline.inc @@ -1,7 +1,7 @@ getopt($argv, $shortoptions, $longoptions); +$result = $parser->getopt($argv, $shortoptions, $longoptions); + +if (PEAR::isError($result)) { + print $result->getMessage()."\n"; + exit(1); +} else { + list($options, $args) = $result; +} function show_help() { global $helptext; $_default_help_text = << 1 && 0 != strncmp($opt, '--', 2)) { + $matches[] = '--'.$opt; + } else { + $matches[] = $opt; + } + + if (!empty($alt)) { + if (strlen($alt) > 1 && 0 != strncmp($alt, '--', 2)) { + $matches[] = '--'.$alt; + } else { + $matches[] = $alt; + } + } + + return $matches; +} + +function have_option($opt, $alt=null) { - global $options; - foreach ($options as $option) { - if ($option[0] == $str) { - return true; - } - } - return false; + global $options; + + $matches = _make_matches($opt, $alt); + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return true; + } + } + + return false; } -function get_option_value($str) +function get_option_value($opt, $alt=null) { - global $options; - foreach ($options as $option) { - if ($option[0] == $str) { - return $option[1]; - } - } - return null; -} \ No newline at end of file + global $options; + + $matches = _make_matches($opt, $alt); + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return $option[1]; + } + } + + return null; +}