forked from kevinowino869/mitrobill
PHPMixBill v5.0 - First Upload
This commit is contained in:
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
|
||||
/**
|
||||
* Class that represent the Callback action.
|
||||
*
|
||||
* The result option array entry value is set to the return value of the
|
||||
* callback defined in the option.
|
||||
*
|
||||
* There are two steps to defining a callback option:
|
||||
* - define the option itself using the callback action
|
||||
* - write the callback; this is a function (or method) that takes five
|
||||
* arguments, as described below.
|
||||
*
|
||||
* All callbacks are called as follows:
|
||||
* <code>
|
||||
* callable_func(
|
||||
* $value, // the value of the option
|
||||
* $option_instance, // the option instance
|
||||
* $result_instance, // the result instance
|
||||
* $parser_instance, // the parser instance
|
||||
* $params // an array of params as specified in the option
|
||||
* );
|
||||
* </code>
|
||||
* and *must* return the option value.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class Callback extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The value of the option
|
||||
* @param array $params An optional array of parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$this->setResult(
|
||||
call_user_func(
|
||||
$this->option->callback,
|
||||
$value,
|
||||
$this->option,
|
||||
$this->result,
|
||||
$this->parser,
|
||||
$params
|
||||
)
|
||||
);
|
||||
}
|
||||
// }}}
|
||||
}
|
84
system/autoload/PEAR2/Console/CommandLine/Action/Counter.php
Normal file
84
system/autoload/PEAR2/Console/CommandLine/Action/Counter.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the Version action.
|
||||
*
|
||||
* The execute methode add 1 to the value of the result option array entry.
|
||||
* The value is incremented each time the option is found, for example
|
||||
* with an option defined like that:
|
||||
*
|
||||
* <code>
|
||||
* $parser->addOption(
|
||||
* 'verbose',
|
||||
* array(
|
||||
* 'short_name' => '-v',
|
||||
* 'action' => 'Counter'
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
* If the user type:
|
||||
* <code>
|
||||
* $ script.php -v -v -v
|
||||
* </code>
|
||||
* or:
|
||||
* <code>
|
||||
* $ script.php -vvv
|
||||
* </code>
|
||||
* the verbose variable will be set to to 3.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class Counter extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An optional array of parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$result = $this->getResult();
|
||||
if ($result === null) {
|
||||
$result = 0;
|
||||
}
|
||||
$this->setResult(++$result);
|
||||
}
|
||||
// }}}
|
||||
}
|
58
system/autoload/PEAR2/Console/CommandLine/Action/Help.php
Normal file
58
system/autoload/PEAR2/Console/CommandLine/Action/Help.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the Help action, a special action that displays the
|
||||
* help message, telling the user how to use the program.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class Help extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An optional array of parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
return $this->parser->displayUsage();
|
||||
}
|
||||
// }}}
|
||||
}
|
69
system/autoload/PEAR2/Console/CommandLine/Action/List.php
Normal file
69
system/autoload/PEAR2/Console/CommandLine/Action/List.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version CVS: $Id: List.php,v 1.2 2009/02/27 08:03:17 izi Exp $
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the List action, a special action that simply output an
|
||||
* array as a list.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class Action_List extends Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
* Possible parameters are:
|
||||
* - message: an alternative message to display instead of the default
|
||||
* message,
|
||||
* - delimiter: an alternative delimiter instead of the comma,
|
||||
* - post: a string to append after the message (default is the new line
|
||||
* char).
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An optional array of parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$list = isset($params['list']) ? $params['list'] : array();
|
||||
$msg = isset($params['message'])
|
||||
? $params['message']
|
||||
: $this->parser->message_provider->get('LIST_DISPLAYED_MESSAGE');
|
||||
$del = isset($params['delimiter']) ? $params['delimiter'] : ', ';
|
||||
$post = isset($params['post']) ? $params['post'] : "\n";
|
||||
$this->parser->outputter->stdout($msg . implode($del, $list) . $post);
|
||||
exit(0);
|
||||
}
|
||||
// }}}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the Password action, a special action that allow the
|
||||
* user to specify the password on the commandline or to be prompted for
|
||||
* entering it.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class Password extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An array of optional parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$this->setResult(empty($value) ? $this->_promptPassword() : $value);
|
||||
}
|
||||
// }}}
|
||||
// _promptPassword() {{{
|
||||
|
||||
/**
|
||||
* Prompts the password to the user without echoing it.
|
||||
*
|
||||
* @return string
|
||||
* @todo not echo-ing the password does not work on windows is there a way
|
||||
* to make this work ?
|
||||
*/
|
||||
private function _promptPassword()
|
||||
{
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
fwrite(
|
||||
STDOUT,
|
||||
$this->parser->message_provider->get('PASSWORD_PROMPT_ECHO')
|
||||
);
|
||||
@flock(STDIN, LOCK_EX);
|
||||
$passwd = fgets(STDIN);
|
||||
@flock(STDIN, LOCK_UN);
|
||||
} else {
|
||||
fwrite(STDOUT, $this->parser->message_provider->get('PASSWORD_PROMPT'));
|
||||
// disable echoing
|
||||
system('stty -echo');
|
||||
@flock(STDIN, LOCK_EX);
|
||||
$passwd = fgets(STDIN);
|
||||
@flock(STDIN, LOCK_UN);
|
||||
system('stty echo');
|
||||
}
|
||||
return trim($passwd);
|
||||
}
|
||||
// }}}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the StoreArray action.
|
||||
*
|
||||
* The execute method appends the value of the option entered by the user to
|
||||
* the result option array entry.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class StoreArray extends CommandLine\Action
|
||||
{
|
||||
// Protected properties {{{
|
||||
|
||||
/**
|
||||
* Force a clean result when first called, overriding any defaults assigned.
|
||||
*
|
||||
* @var object $firstPass First time this action has been called.
|
||||
*/
|
||||
protected $firstPass = true;
|
||||
|
||||
// }}}
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An optional array of parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$result = $this->getResult();
|
||||
if (null === $result || $this->firstPass) {
|
||||
$result = array();
|
||||
$this->firstPass = false;
|
||||
}
|
||||
$result[] = $value;
|
||||
$this->setResult($result);
|
||||
}
|
||||
// }}}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the StoreFalse action.
|
||||
*
|
||||
* The execute method store the boolean 'false' in the corrsponding result
|
||||
* option array entry (the value is true if the option is not present in the
|
||||
* command line entered by the user).
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class StoreFalse extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An array of optional parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$this->setResult(false);
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the StoreFloat action.
|
||||
*
|
||||
* The execute method store the value of the option entered by the user as a
|
||||
* float in the result option array entry, if the value passed is not a float
|
||||
* an Exception is raised.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class StoreFloat extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An array of optional parameters
|
||||
*
|
||||
* @return string
|
||||
* @throws PEAR2\Console\CommandLine\Exception
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
throw CommandLine\Exception::factory(
|
||||
'OPTION_VALUE_TYPE_ERROR',
|
||||
array(
|
||||
'name' => $this->option->name,
|
||||
'type' => 'float',
|
||||
'value' => $value
|
||||
),
|
||||
$this->parser
|
||||
);
|
||||
}
|
||||
$this->setResult((float)$value);
|
||||
}
|
||||
// }}}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the StoreInt action.
|
||||
*
|
||||
* The execute method store the value of the option entered by the user as an
|
||||
* integer in the result option array entry, if the value passed is not an
|
||||
* integer an Exception is raised.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class StoreInt extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An array of optional parameters
|
||||
*
|
||||
* @return string
|
||||
* @throws PEAR2\Console\CommandLine\Exception
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
throw CommandLine\Exception::factory(
|
||||
'OPTION_VALUE_TYPE_ERROR',
|
||||
array(
|
||||
'name' => $this->option->name,
|
||||
'type' => 'int',
|
||||
'value' => $value
|
||||
),
|
||||
$this->parser
|
||||
);
|
||||
}
|
||||
$this->setResult((int)$value);
|
||||
}
|
||||
// }}}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the StoreString action.
|
||||
*
|
||||
* The execute method store the value of the option entered by the user as a
|
||||
* string in the result option array entry.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class StoreString extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An array of optional parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$this->setResult((string)$value);
|
||||
}
|
||||
// }}}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the StoreTrue action.
|
||||
*
|
||||
* The execute method store the boolean 'true' in the corrsponding result
|
||||
* option array entry (the value is false if the option is not present in the
|
||||
* command line entered by the user).
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class StoreTrue extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An array of optional parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
$this->setResult(true);
|
||||
}
|
||||
// }}}
|
||||
}
|
58
system/autoload/PEAR2/Console/CommandLine/Action/Version.php
Normal file
58
system/autoload/PEAR2/Console/CommandLine/Action/Version.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* This file is part of the PEAR2\Console\CommandLine package.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: This source file is subject to the MIT license that is available
|
||||
* through the world-wide-web at the following URI:
|
||||
* http://opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 0.2.1
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since File available since release 0.1.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace PEAR2\Console\CommandLine\Action;
|
||||
|
||||
use PEAR2\Console\CommandLine;
|
||||
|
||||
/**
|
||||
* Class that represent the Version action, a special action that displays the
|
||||
* version string of the program.
|
||||
*
|
||||
* @category Console
|
||||
* @package PEAR2\Console\CommandLine
|
||||
* @author David JEAN LOUIS <izimobil@gmail.com>
|
||||
* @copyright 2007-2009 David JEAN LOUIS
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @link http://pear2.php.net/PEAR2_Console_CommandLine
|
||||
* @since Class available since release 0.1.0
|
||||
*/
|
||||
class Version extends CommandLine\Action
|
||||
{
|
||||
// execute() {{{
|
||||
|
||||
/**
|
||||
* Executes the action with the value entered by the user.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
* @param array $params An array of optional parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function execute($value = false, $params = array())
|
||||
{
|
||||
return $this->parser->displayVersion();
|
||||
}
|
||||
// }}}
|
||||
}
|
Reference in New Issue
Block a user