2017 © Pedro Peláez
 

library php-argv

A library for process php argv in command line.

image

codecounter/php-argv

A library for process php argv in command line.

  • Thursday, January 29, 2015
  • by codecounter
  • Repository
  • 1 Watchers
  • 4 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 46 % Grown

The README.md

php-argv

A library for process php argv in command line., (*1)

Installation

With composer, (*2)

{
    ...
    "require": {
        "codecounter/php-argv": "0.1.0"
    }
}

Without composer, (*3)

require '/path/to/php-argv/autoload.php';

Usage

// first, create a php-argv instance
$phpArgv = new \CodeCounter\PHPArgv\Argv();

// set version, desc
$phpArgv->version('1.0.0')
    ->desc('Some description for this command');

// create default module(sub command)
$phpArgv->module()
    // set description for this module
    ->desc()
    // set allowed options
    ->options(array(
        array(
            'key' => 'num',
            'type' => 'int'
        ),
        array(
            'key' => 'path',
            'type '=> 'path'
        )
    ))
    ->onProcess(function ($module, $options) {
        if (empty($options) || isset($options['help'])) {
            $module->defaultHelp();
        }

        // other logic
    });

// create another module
$phpArgv->module('another-module')
    ...

// parse argv, default is global argv
$phpArgv->parse();

Documentation

[complete later], (*4)

Test

cd /path/to/php-argv/tests
php index.php --help

The Versions

29/01 2015

dev-master

9999999-dev

A library for process php argv in command line.

  Sources   Download

MIT

by Avatar codecounter