Download the PHP package d0riven/php-flags without Composer
On this page you can find all versions of the php package d0riven/php-flags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-flags
PHP Flags
This library is a parser of command line arguments that can be used sensibly without looking at the documentation.
Feature
- Explicit declarations.
- Support for required, optional and multiple values.
- Check type of value.
- Simple notation.
- Automatic generation of usage.
Installation
todo write
Usage
Method chain declaration
example of ping command.
If you want to see other examples, see the script under examples/chain/
.
Usage is automatically generated without any special configuration.
Since version is defined, you can check the version with --version flag.
Document
Support Type
- int
- float
- bool
- string
- date
Build flag and arg options
method name | description |
---|---|
desc | Set description. |
default | Set default value. If the default value is not specified, it is treated as a required flag (other bool). |
validRule | Set a callback that throws an exception as an invalid value if false is returned. Expected callback format is f($value) { return boolean; } |
multiple | Allow multiple option values. (e.g. If -f 1 -f 2 -f 3, get values [1, 2, 3]) |
Build flag additional option
method name | description |
---|---|
short | Enable short flag and set short flag name. |
Help flag additional option
method name | description |
---|---|
long | Replace long flag name from "help". |
short | Replace short flag name from "h". |
clearShort | Disable short flag. |
Version flag additional option
method name | description |
---|---|
long | Replace long flag name from "version". |
short | Replace short flag name from "v". |
clearShort | Disable short flag. |
Custom help
Help is defined by default and the flags consist of --help and -h.
If these flags are specified on the command line, it will normally output a formatted help message and exit at parse time with status 0.
It is possible to change the flags and customize the behavior when they are specified.
If you want to see more info, see the script under examples/chain/customVersionHelp.php
.
Changed the flag value from "help" to "show-help", short from "h" to "s", and the exit status code from "0" to "1".
Custom version
Changed the flag value from "version" to "ver", short from "v" to upper "V", and the exit status code from "0" to "1".