Download the PHP package troublete/argv without Composer
On this page you can find all versions of the php package troublete/argv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download troublete/argv
More information about troublete/argv
Files in troublete/argv
Package argv
Short Description Small functional library to interpret CLI arguments
License GPL-2.0
Informations about the package argv
Argv
Small functional library to interpret CLI arguments ✨
Install
Usage
On CLI execution like $ php file-with-script.php --rainbow
the CLI will output rainbow 🌈
. (see examples
for a working example)
API
Methods
cleanArguments(array $argv): string
Will remove the script from the input arguments.
reduceFlagName(string $flagName): string
Will remove -
and --
from flags and flag aliases.
isCommandCall(array $arguments): bool
Will determine by checking the first argument if a command is called or only a flag call is occuring.
isFlag(string $argument): bool
Will determine if argument is a flag by checking if first two characters are --
.
isFlagAlias(string $argument): bool
Will determine if argument is a flag alias by checking if the first character is -
.
getFlags(array $arguments, array $aliases = []): class@anonymous
Will return an class with all flags (NOT aliases) as public properties, value set to true or the value with the following index of the flag.
If aliases are provided in the form like ['f' => 'flag']
the flag flag
will be set on script call with only -f
.
getValues(array $arguments): class@anonymous
Will return all provided values encapsulated in a anonymous class (original index will be preserved). With calling ->all()
on the returned class an array with all values will be returned, where key is original index and value the value. With calling ->first()
the first value will be returned.
getCommand(array $arguments): string
Alias method to return the command name off the values, if set.
License
GPL-2.0 Willi Eßer