Coder Social home page Coder Social logo

php-cli-tools's Introduction

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\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.

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 example_args.php for an example.

Usage

See example.php for examples.

Todo

  • Expand this README
  • Add doc blocks to rest of code

php-cli-tools's People

Contributors

danielbachhuber avatar dllh avatar dsawardekar avatar hskrtich avatar igorsantos07 avatar jesseoverright avatar jlogsdon avatar juliopotier avatar lucasvanlierop avatar nyholm avatar scribu avatar thanj avatar tollmanz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.