2017 © Pedro Peláez
 

library php-cli-tools

Console utilities for PHP

image

titpetric/php-cli-tools

Console utilities for PHP

  • Monday, September 16, 2013
  • by titpetric
  • Repository
  • 1 Watchers
  • 0 Stars
  • 48 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 95 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

PHP Command Line Tools

A collection of functions and classes to assist with command line development., (*1)

Requirements, (*2)

  • PHP >= 5.3
  • git_hooks - optional, for some git hooks
  • phpunit - optional, for running tests

If you can, please use composer to install and use php-cli-tools from titpetric/php-cli-tools., (*3)

Run composer require titpetric/php-cli-tools to get started. Stability dev-master should be ok., (*4)

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\notifier\Dots($msg, $dots = 3, $interval = 100)
  • \cli\notifier\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., (*5)

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., (*6)

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., (*7)

Usage

Check examples/ folder for various examples. Also check out tests if you want to see how some features actually work and are used., (*8)

Todo

  • Expand this README
  • Add doc blocks to rest of code
  • Increase code coverage with phpunit tests

The Versions

16/09 2013

dev-master

9999999-dev http://github.com/titpetric/php-cli-tools

Console utilities for PHP

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

php console cli php cli

30/10 2012

dev-fix-php-5.3.1

dev-fix-php-5.3.1 http://github.com/jlogsdon/php-cli-tools

Console utilities for PHP

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

console cli