wp-cli / php-cli-tools
Console utilities for PHP
Installs: 16 833 918
Dependents: 399
Suggesters: 2
Security: 0
Stars: 677
Watchers: 33
Forks: 118
Open Issues: 9
Requires
- php: >= 5.6.0
Requires (Dev)
- roave/security-advisories: dev-latest
- wp-cli/wp-cli-tests: ^4
- v0.12.1
- v0.12.0
- dev-master / 0.11.x-dev
- v0.11.22
- v0.11.21
- v0.11.20
- v0.11.19
- v0.11.18
- v0.11.17
- v0.11.16
- v0.11.15
- v0.11.14
- v0.11.13
- v0.11.12
- v0.11.11
- v0.11.10
- v0.11.9
- v0.11.8
- v0.11.7
- v0.11.6
- v0.11.5
- v0.11.4
- v0.11.3
- v0.11.2
- v0.11.1
- v0.11.0
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.5
- v0.9.4-patch46
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1.1
- v0.9.1
- v0.9
This package is auto-updated.
Last update: 2024-12-16 13:13:18 UTC
README
A collection of functions and classes to assist with command line development.
Requirements
- PHP >= 5.6
Suggested PHP extensions
- mbstring - Used for calculating string widths.
Function List
cli\out($msg, ...)
cli\out_padded($msg, ...)
cli\err($msg, ...)
cli\line($msg = '', ...)
cli\input()
cli\prompt($question, $default = false, $marker = ':')
cli\choose($question, $choices = 'yn', $default = 'n')
cli\menu($items, $default = false, $title = 'Choose an Item')
Progress Indicators
cli\notify\Dots($msg, $dots = 3, $interval = 100)
cli\notify\Spinner($msg, $interval = 100)
cli\progress\Bar($msg, $total, $interval = 100)
Tabular Display
cli\Table::__construct(array $headers = null, array $rows = null)
cli\Table::setHeaders(array $headers)
cli\Table::setRows(array $rows)
cli\Table::setRenderer(cli\table\Renderer $renderer)
cli\Table::addRow(array $row)
cli\Table::sort($column)
cli\Table::display()
The display function will detect if output is piped and, if it is, render a tab delimited table instead of the ASCII table rendered for visual display.
You can also explicitly set the renderer used by calling cli\Table::setRenderer()
and giving it an instance of one
of the concrete cli\table\Renderer
classes.
Tree Display
cli\Tree::__construct()
cli\Tree::setData(array $data)
cli\Tree::setRenderer(cli\tree\Renderer $renderer)
cli\Tree::render()
cli\Tree::display()
Argument Parser
Argument parsing uses a simple framework for taking a list of command line arguments,
usually straight from $_SERVER['argv']
, and parses the input against a set of
defined rules.
Check examples/arguments.php
for an example.
Usage
See examples/
directory for examples.
Todo
- Expand this README
- Add doc blocks to rest of code