2017 © Pedro Peláez
 

library clearice

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

image

ekowabaka/clearice

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  • Monday, July 23, 2018
  • by ekowabaka
  • Repository
  • 3 Watchers
  • 2 Stars
  • 2,974 Installations
  • PHP
  • 8 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 31 Versions
  • 6 % Grown

The README.md

ClearIce PHP Command Line Argument Parser

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads, (*1)

ClearIce provides tools for PHP applications to help with parsing command line arguments, and performing interactive I/O sessions. Arguments supplied at the command line or through a shell are validated and supplied to your script in a consistently organized format. And gues what, there's also the added possibility of automatically generating help messages for your applications., (*2)

Installing

Although you can directly include the ClearIce scripts into your application, the best way of installing it is through composer., (*3)

composer require ekowabaka/clearice

ClearIce has no dependencies other than a PHP interpreter with version 7.1 or better., (*4)

Parsing Arguments with ClearICE

Let's get started with an example. If you ever wanted to parse command line arguments you can put ..., (*5)

<?php
require "vendor/autoload.php";

$parser = new \clearice\argparser\ArgumentParser();
$parser->addOption([
    'name' => 'input',
    'short_name' => 'i',
    'type' => 'string',
    'required' => true
]);

$parser->addOption([
    'name' => 'output',
    'short_name' => 'o',
    'type' => 'string',
    'default' => '/default/output/path'
]);

$options = $parser->parse($argv);
print_r($options);

... in a file (which you can for example save as wiki.php). Then when you execute ..., (*6)

php wiki.php generate --input=/home/james --output=/var/www/cool-wiki

... the output will be ..., (*7)

Array
(
    [input] => /input/path
    [output] => /output/path
    [__executed] => wiki.php
)

... and so will the following:, (*8)

php test.php --input /input/path --output /output/path
php test.php -i/input/path -o/output/path

Interactive I/O with ClearICE

If you are interested in interactive I/O, entering this, (*9)

use clearice\io\Io;
$io = new Io();
$name = $io->getResponse('What is your name', ['default' => 'No Name']);

$direction = $io->getResponse("Okay $name, where do you want to go", 
    [
        'required' => true,
        'answers' => array('north', 'south', 'east', 'west')
    ]
); 

could lead to an interaction like this:, (*10)

What is your name [No Name]: ⏎
Okay No Name, where do you want to go (north/south/east/west) []: ⏎
A value is required.
Okay No Name, where do you want to go (north/south/east/west) []: home⏎
Please provide a valid answer.
Okay No Name, where do you want to go (north/south/east/west) []: 

Hope you enjoy using ClearIce!, (*11)

The Versions

23/07 2018

dev-dev

dev-dev

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

24/09 2017

dev-master

9999999-dev

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

23/09 2017

v2.0.0

2.0.0.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Development Requires

27/06 2017

v1.x-dev

1.9999999.9999999.9999999-dev

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Development Requires

27/06 2017

v1.1.0

1.1.0.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Development Requires

17/12 2016

v1.0.0

1.0.0.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

17/12 2016

v1.0.0-rc2

1.0.0.0-RC2

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

22/11 2016

v1.0.0-rc1

1.0.0.0-RC1

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

25/03 2016

v0.6.1

0.6.1.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

25/03 2016

v0.6.0

0.6.0.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

06/12 2015

v0.5.0

0.5.0.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

25/11 2015

v0.4.4

0.4.4.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

09/05 2015

v0.4.3

0.4.3.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

31/01 2015

v0.4.2

0.4.2.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

08/01 2015

v0.4.1

0.4.1.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

19/12 2014

v0.4.0

0.4.0.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

22/10 2014

v0.3.2

0.3.2.0

A tool to help in the building of CLI apps. Provides command line parsing and simple console I/O interfaces.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

  • mikey179/vfsstream v1.3.0

25/09 2014

v0.3.1

0.3.1.0

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

  • mikey179/vfsstream v1.3.0

14/09 2014

v0.3.0

0.3.0.0

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

  • mikey179/vfsstream v1.3.0

02/09 2014

v0.3.0-beta2

0.3.0.0-beta2

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

22/08 2014

v0.3.0-alpha3

0.3.0.0-alpha3

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

22/08 2014

0.3.0-beta

0.3.0.0-beta

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

11/08 2014

0.3.0-alpha2

0.3.0.0-alpha2

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

08/08 2014

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

04/08 2014

dev-non_static

dev-non_static

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

04/08 2014

0.3.0-alpha

0.3.0.0-alpha

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

12/07 2014

0.2.4

0.2.4.0

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

10/04 2014

0.2.3

0.2.3.0

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

29/03 2014

v0.2.2

0.2.2.0

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

29/03 2014

v0.2.1

0.2.1.0

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

29/03 2014

v0.2.0

0.2.0.0

A tool for parsing command line arguments

  Sources   Download

MIT

The Requires

  • php >=5.3.0