Download the PHP package wp-php-toolkit/cli without Composer
On this page you can find all versions of the php package wp-php-toolkit/cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wp-php-toolkit/cli
More information about wp-php-toolkit/cli
Files in wp-php-toolkit/cli
Package cli
Short Description CLI component for WordPress.
License GPL-2.0-or-later
Homepage https://wordpress.github.io/php-toolkit/reference/cli.html
Informations about the package cli
slug: cli title: CLI install: wp-php-toolkit/cli
see_also:
- filesystem | Filesystem | Keep command behavior testable with in-memory storage.
- blueprints | Blueprints | Build repeatable site setup commands around parsed options.
-
httpserver | HttpServer | Add a local web UI to a CLI workflow.
POSIX-style argument parser. Long options, short bundles, inline values, positional args — one static call.
Why this exists
Real CLI tools in PHP usually mean either pulling in symfony/console (and the transitive dependencies that come with it) or hand-rolling argv parsing that breaks the first time someone writes -vvv or --port=8080. The toolkit's CLI class is one static method, no dependencies, and handles the POSIX shapes you actually see.
Parse a single flag
The smallest useful invocation: one boolean flag, one positional. Each option is a four-tuple of [ short, has_value, default, description ].
Mix values, flags, and bundles
The parser accepts --port 8080, --port=8080, -p 8080, and -p=8080. It also expands bundled boolean shorts such as -afv.
Validate required options
The parser fills in defaults but never enforces "required". Check for null after parsing — full control over the error message.
Generate --help from definitions
Because each option carries its own description, you can render help text by walking the same definitions you parse with. No second source of truth.
Git-style subcommands
To build a tool with subcommands like mytool deploy, peel the first positional off argv, dispatch, and parse the rest with a per-command option set.