Project

General

Profile

Bug #21389 » cli_arguments.patch

Administrator Admin, 2009-10-28 11:43

View differences:

typo3/sysext/lowlevel/class.tx_lowlevel_cleaner_core.php (working copy)
*/
function cli_main($argv) {
$this->cli_setArguments($argv);
// Force user to admin state and set workspace to "Live":
$GLOBALS['BE_USER']->user['admin'] = 1;
$GLOBALS['BE_USER']->setWorkspace(0);
t3lib/class.t3lib_cli.php (working copy)
*/
function t3lib_cli() {
// Loads the cli_args array with command line arguments
$this->cli_args = $this->cli_getArgIndex();
$this->cli_setArguments($_SERVER['argv']);
}
/**
......
* Argument names (eg. "-s") will be keys and values after (eg. "-s value1 value2 ..." or "-s=value1") will be in the array.
* Array is empty if no values
*
* @param array $argv Configuration options
* @return array
*/
function cli_getArgIndex() {
function cli_getArgIndex ($argv) {
$cli_options = array();
$index = '_DEFAULT';
foreach($_SERVER['argv'] as $token) {
if (!is_array($argv)) {
$argv = array();
}
foreach($argv as $token) {
if ($token{0}==='-' && !t3lib_div::testInt($token{1})) { // Options starting with a number is invalid - they could be negative values... !
list($index,$opt) = explode('=',$token,2);
if (isset($cli_options[$index])) {
......
}
/**
* Set environment array to $cli_args
*
* @param array $argv Configuration options
* @return void
*/
function cli_setArguments ($argv) {
$this->cli_args = $this->cli_getArgIndex ($argv);
}
/**
* Asks stdin for keyboard input and returns the line (after enter is pressed)
*
* @return string
(1-1/2)