alphayax/get_opt

Utility class for manage scripts arguments

1.0.2 2017-11-16 07:51 UTC

README

A library to manage scripts arguments

Latest Stable Version Latest Unstable Version pakagist

Travis Coverage Status Codacy Badge

License Total Downloads

GetOpt

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');

Auto-generated Help

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