Getting somewhere, using PEAR ConsoleGetopt for arguments

This commit is contained in:
2013-04-13 23:54:29 +02:00
parent 2dee6601f6
commit bd676d52e8
3 changed files with 41 additions and 3 deletions

BIN
.check_md5.php.swp Normal file

Binary file not shown.

View File

@@ -1,5 +1,9 @@
#!/usr/bin/php5
<?php
//include class file
include ("Console/Getopt.php");
$VERSION="1.1";
$AUTHOR="(c) 2012 Jack-Benny Persson (jack-benny@cyberinfo.se)";
@@ -46,7 +50,40 @@ EOD;
echo "\n$HELP_TEXT\n";
}
$options = new Console_Getopt();
$shortoptions = "hV";
$longoptions = array("warning", "file", "md5");
$args = $options->readPHPArgv();
$ret = $options->getopt($args, $shortoptions, $longoptions);
if (PEAR::isError($ret)) {
fwrite(STDERR,$ret->getMessage() . "\n");
exit ($STATE_UNKNOWN);
}
$opts = $ret[0];
if(sizeof($opts) > 0)
{
foreach($opts as $o)
{
switch($o[0])
{
case 'h':
print_help();
break;
case 'V':
print_version();
break;
}
}
}
$file = 'fil';
echo md5_file($file);
?>

1
fil Normal file
View File

@@ -0,0 +1 @@
Hejsan