php-cli-tools

A collection of tools to help with PHP command line utilities

Github星跟蹤圖

PHP Command Line Tools

Build Status

A collection of functions and classes to assist with command line development.

Requirements

  • PHP >= 5.3

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

主要指標

概覽
名稱與所有者wp-cli/php-cli-tools
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2010-03-31 00:53:08
推送於2025-05-12 20:05:28
最后一次提交2025-05-12 16:05:26
發布數43
最新版本名稱v0.12.5 (發布於 )
第一版名稱v0.9 (發布於 )
用户参与
星數680
關注者數32
派生數117
提交數356
已啟用問題?
問題數69
打開的問題數7
拉請求數92
打開的拉請求數2
關閉的拉請求數22
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?