X-Git-Url: https://git.ao2.it/tweeper.git/blobdiff_plain/110456377908327064a91a48e1f4c2c810b848fa..d38cac35c8e0aed0a223533bb54e46958c693212:/tweeper.php?ds=inline diff --git a/tweeper.php b/tweeper.php index 11e062b..45bc786 100644 --- a/tweeper.php +++ b/tweeper.php @@ -137,7 +137,7 @@ function usage($argv) if (php_sapi_name() != 'cli') $usage = htmlentities("{$_SERVER['SCRIPT_NAME']}?src_url="); else - $usage = "{$argv[0]} \n"; + $usage = "{$argv[0]} [-h|--help] \n"; return "usage: $usage"; } @@ -149,10 +149,19 @@ function parse_options_cli($argv, $argc) if ($argc < 2) return $options; - if ($argv[1] == "-h" || $argv[1] == "--help") - echo usage($argv); - else - $options['src_url'] = $argv[1]; + $cli_options = getopt("h", array("help")); + foreach ($cli_options as $opt => $val) { + switch ($opt) { + case 'h': + case 'help': + echo usage($argv); + exit(0); + default: + die(usage($argv)); + } + } + + $options['src_url'] = $argv[count($cli_options) + 1]; return $options; }