Getting somewhere, using PEAR ConsoleGetopt for arguments
This commit is contained in:
BIN
.check_md5.php.swp
Normal file
BIN
.check_md5.php.swp
Normal file
Binary file not shown.
@@ -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);
|
||||
|
||||
?>
|
||||
|
||||
|
Reference in New Issue
Block a user