2017 © Pedro Peláez
 

library reactor

image

d2g/reactor

  • Sunday, January 29, 2017
  • by DimitriGilbert
  • Repository
  • 1 Watchers
  • 1 Stars
  • 38,377 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

Command line micro-framework in php

why another cli tool ?

Because i did not find anything simple enough to use. This is, in my opinion, quiet simple and will handle most of the nee i can think of concerning cli., (*1)

Create your command line

extend reactor command class

class Mycommand extends \D2G\Reactor\Command

define your methods and required argument/options

function __construct($args, $opts, $flags)
{
    parent::construct($args, $opts, $flags);
    $this->commands = array(
        '<pre>__DEFAULT__</pre>'=>'__help',
        // the name of your method
        'my_method'=>array(
            // defining expected inputs 
            'expecting'=>array(
                // defining expected arguments
                'args'=>array(
                    array(
                        // used in error message
                        'name'=>'my-argument',
                        // internal function will try to cast the argument to this type
                        'type'=>'type of argument',
                        // command will fail if an expected argument is not present
                        'required'=>true|false
                    )
                ),
                // defining expected options
                'opts'=>array(
                    // option name used in cli prefixed with --
                    'option-name'=>array(
                        // internal function will try to cast the argument to this type
                        'type'=>'string',
                        // command will fail if an expected argument is not present
                        'required'=>true|false
                        // default value assigned to the options if not given
                        'default'=>''
                    )
                )
                // defining expected flags
                'args'=>array(
                    array(
                        // flags
                        'a',
                        'longflag'
                    )
                ),
            ),
        )
    );
}

Usage

Basic

on *nix, (*2)

[php ][vendor/bin/]reactor Your/Command/Class/FQN/With/Slashes:yourCommandMethod firstArg secondArg --myOption=myOptionValue --myOtherOpt="value encapsed" -longFlag -a

The Versions

29/01 2017

0.x-dev

0.9999999.9999999.9999999-dev

  Sources   Download

The Requires

 

29/01 2017

v0.2.0

0.2.0.0

  Sources   Download

The Requires

 

28/04 2016

dev-master

9999999-dev

  Sources   Download

The Requires

 

19/02 2015

0.1.x-dev

0.1.9999999.9999999-dev

  Sources   Download

The Requires