Download the PHP package appertly/cleopatra without Composer
On this page you can find all versions of the php package appertly/cleopatra. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cleopatra
cleopatra
A command line argument parser better than the builtin getopt for Hack/HHVM.
It got its name because it parses CLI opt ions.
Installation
You can install this library using Composer:
- The master branch (version 0.x) of this project requires HHVM 3.12 and has no dependencies.
Compliance
Releases of this library will conform to Semantic Versioning.
Our code is intended to comply with PSR-1, PSR-2, and PSR-4. If you find any issues related to standards compliance, please send a pull request!
Features
Users can specify command line options pretty much how you'd expect from typical shell conventions.
- Short options
- Multiple short options can be bundled together (e.g.
-abcdef
) - Short options with required values can be specified either with a space or without (e.g.
-d2
or-d 2
) - Short options with optional values must be specified without a space (e.g.
-d2
) - Short options without values can be bundled with those with values (e.g.
-abcd 2
)
- Multiple short options can be bundled together (e.g.
- Long options
- Long options with required values can be specified either with an equals sign or a space (e.g.
--foo bar
or--foo="bar"
) - Long options with optional values must be specified with an equals sign (e.g.
--foo
or--foo="bar"
)
- Long options with required values can be specified either with an equals sign or a space (e.g.
- Normal arguments
- Options can be specified in any order among regular arguments (e.g.
command -a value -b argument1 --opt="value" -c argument2 argument3
) - A real-world example of this:
aws --profile mine ec2 start-instances --instance-ids i-123456
- Arguments can be separated from all options with a double dash (e.g.
command -a value -xyz -- argument1 argument2 argument3
)
- Options can be specified in any order among regular arguments (e.g.
- Automatic help documentation
Usage
Specification
For simplicity, we stuck to a combination of
PHP's own getopt
function and
Perl's Getopt::Long.
[label][constraints][type]
- The label contains aliases for the option, separated with a pipe (
|
), e.g.l|length
- Labels must only consist of alphanumeric characters and the dash (e.g.
[a-zA-Z0-9\-]
)
- Labels must only consist of alphanumeric characters and the dash (e.g.
- The constraint dictates how the option can be used
- A plus (
+
) marks an option as incremental (e.g.-vvv
) - A colon (
:
) marks an option as having a required value - Two colons (
::
) marks an option as non-required; a value can be specified with equals (e.g--option="foo"
)
- A plus (
- The type can be used to specify how the argument value is evaluated
s
= string,i
= integer,f
= float,d
=DateTimeImmutable
- A trailing at sign (
@
) will store multiple arguments in aVector
(e.g.-d 1.txt -d 2.txt -d 3.txt
)
Examples
Samples
Here's a quick example.
The contents of test.hh:
You run:
You get:
You run:
You get: