Download the PHP package shso/cli without Composer
On this page you can find all versions of the php package shso/cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package cli
Short Description Usefull cli related functions
License MIT
Homepage https://github.com/ShahinSorkh/php-cli
Informations about the package cli
php-cli
Enhance php cli scripts experiance.
Install
Use Composer
Composer will load the library automatically.
Manually
Download the script:
Import in your scripts:
Script Usage
Assuming following cli:
Count arguments
Get arguments
Get options
Define usage
You can define a strict usage with fixed options and arguments.
To do so, you should use cli\usage()
method which takes an array as
argument with possible keys of args
, opts
, desc
.
Define arguments
Arguments can be optional.
Define options
Options can be optional and can accept arguments. Also options can be short or long.
Define additional descriptions
If you need to describe about options or arguments, you can do so.
Command Line Usage
This package supports following syntax:
Passing arguments
- Arguments has to be the last values. This means the following syntax is not acceptable:
Whenever an argument detected, every value after that is considered arguments.
Means all of ARG1
, --opt1
, ARG2
, --opt2
, OPT2_ARG
, ARG3
, ARG4
,
are separate arguments.
- Every non-option value after an option, is considered the argument of the
option. This means in the following syntax,
ARG1
would be available as the value of the--op1
option (see below):
If you need a boolean option and some arguments, use --
before arguments.
like:
- If you need input from
stdin
, use-
. like:
It is possible to pass other arguments and options alongside.
Passing options
Every passed value starting with -
before the first detected argument, is an
option. Options can get additional value as their argument. like:
If you are going to pass arguments, options has to be terminated with --
. like: