A library to manage scripts arguments
A class to parse parameters given to a script
$Args = new GetOpt();
$Args->addShortOpt( 'd', 'Debug mode');
$Args->addLongOpt( 'dry-run', 'Dry Run mode');
$Args->addOpt( 'v', 'verbose', 'Verbose Mode');
$Args->parse();
$isDryRun = $Args->hasOption( 'dry-run');
$isVerbose = $Args->hasOption( 'v') || $Args->hasOption( 'verbose');
Example of help output (if the -h or --help flag is specified) :
Description
This script is a tiny example to show library features
Usage
/usr/bin/php a.php [OPTIONS]
Options
-d Debug mode
--dry-run Dry Run mode
--file <value> Specify the file name
-h --help Display help
-n <value> [REQUIRED] Number of lines
-v --verbose Verbose Mode