X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fcommandline.inc;h=9029bb19db4e7df9879d73fccbb4b792124c8599;hb=971f1f64f1f42a51bced51665ae693a9d37750a0;hp=9c6787cb7a299e03c9aac6fbec035e661184c5d2;hpb=0c3bfc2212ef74cacac73e670ff063124bd67af5;p=quix0rs-gnu-social.git diff --git a/scripts/commandline.inc b/scripts/commandline.inc index 9c6787cb7a..9029bb19db 100644 --- a/scripts/commandline.inc +++ b/scripts/commandline.inc @@ -1,7 +1,7 @@ getopt($argv, $shortoptions, $longoptions); if (PEAR::isError($result)) { - print $result->getMessage()."\n"; - exit(1); + print $result->getMessage()."\n"; + exit(1); } else { - list($options, $args) = $result; + list($options, $args) = $result; } function show_help() @@ -77,7 +78,7 @@ 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; - - $matches = array($opt); - - if (strlen($opt) > 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; - } - } - - foreach ($options as $option) { - if (in_array($option[0], $matches)) { - 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, $alt=null) +function get_option_value($opt, $alt=null) { - global $options; - - $matches = array(); - - if (strlen($opt) > 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; - } - } - - foreach ($options as $option) { - if (in_array($option[0], $matches)) { - 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; +}