X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fcommandline.inc;h=9029bb19db4e7df9879d73fccbb4b792124c8599;hb=48782ee1d9c99a3e17ed2973fffd478c97603c6a;hp=4a7757fb98f13e43c47bf55cdd0841da848304fd;hpb=205d8afe546b385100103dafc439d0397c36cbf4;p=quix0rs-gnu-social.git diff --git a/scripts/commandline.inc b/scripts/commandline.inc index 4a7757fb98..9029bb19db 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 get_option_value($str) +function have_option($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 true; + } + } + + return false; +} + +function get_option_value($opt, $alt=null) +{ + global $options; + + $matches = _make_matches($opt, $alt); + + foreach ($options as $option) { + if (in_array($option[0], $matches)) { + return $option[1]; + } + } + + return null; +}