TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Controller\CommandLineController Class Reference
Inheritance diagram for TYPO3\CMS\Core\Controller\CommandLineController:
t3lib_cli TYPO3\CMS\Lowlevel\AdminCommand TYPO3\CMS\Lowlevel\CleanerCommand tx_lowlevel_admin_core tx_lowlevel_cleaner_core TYPO3\CMS\Lowlevel\CleanFlexformCommand TYPO3\CMS\Lowlevel\DeletedRecordsCommand TYPO3\CMS\Lowlevel\DoubleFilesCommand TYPO3\CMS\Lowlevel\LostFilesCommand TYPO3\CMS\Lowlevel\MissingFilesCommand TYPO3\CMS\Lowlevel\MissingRelationsCommand TYPO3\CMS\Lowlevel\OrphanRecordsCommand TYPO3\CMS\Lowlevel\RteImagesCommand TYPO3\CMS\Lowlevel\SyslogCommand TYPO3\CMS\Lowlevel\VersionsCommand

Public Member Functions

 __construct ()
 
 cli_getArgArray ($option, $argv)
 
 cli_isArg ($option)
 
 cli_argValue ($option, $idx=0)
 
 cli_getArgIndex (array $argv=array())
 
 cli_validateArgs ()
 
 cli_setArguments (array $argv=array())
 
 cli_keyboardInput ()
 
 cli_keyboardInput_yes ($msg='')
 
 cli_echo ($string='', $force=FALSE)
 
 cli_help ()
 
 cli_indent ($str, $indent)
 

Public Attributes

 $cli_args = array()
 
 $cli_options
 
 $cli_help
 
 $stdin = NULL
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Contains base class for TYPO3 cli scripts

Author
Kasper Skårhøj kaspe.nosp@m.rYYY.nosp@m.Y@typ.nosp@m.o3.c.nosp@m.om TYPO3 cli script basis
Kasper Skårhøj kaspe.nosp@m.rYYY.nosp@m.Y@typ.nosp@m.o3.c.nosp@m.om

Definition at line 26 of file CommandLineController.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Controller\CommandLineController::__construct ( )

Constructor Make sure child classes also call this!

Returns
void
Todo:
Define visibility

Definition at line 68 of file CommandLineController.php.

References TYPO3\CMS\Core\Controller\CommandLineController\cli_setArguments().

Member Function Documentation

◆ cli_argValue()

TYPO3\CMS\Core\Controller\CommandLineController::cli_argValue (   $option,
  $idx = 0 
)

◆ cli_echo()

TYPO3\CMS\Core\Controller\CommandLineController::cli_echo (   $string = '',
  $force = FALSE 
)

Echos strings to shell, but respective silent-modes

Parameters
string$stringThe string
boolean$forceIf string should be written even if -s is set (-ss will subdue it!)
Returns
boolean Returns TRUE if string was outputted.
Todo:
Define visibility

Definition at line 232 of file CommandLineController.php.

Referenced by TYPO3\CMS\Core\Controller\CommandLineController\cli_help(), TYPO3\CMS\Lowlevel\AdminCommand\cli_main(), TYPO3\CMS\Lowlevel\CleanerCommand\cli_main(), and TYPO3\CMS\Lowlevel\CleanerCommand\cli_printInfo().

◆ cli_getArgArray()

TYPO3\CMS\Core\Controller\CommandLineController::cli_getArgArray (   $option,
  $argv 
)

Finds the arg token (like "-s") in argv and returns the rest of argv from that point on. This should only be used in special cases since this->cli_args should already be prepared with an index of values!

Parameters
string$optionOption string, eg. "-s
array$argvInput argv array
Returns
array Output argv array with all options AFTER the found option.
Todo:
Define visibility

Definition at line 82 of file CommandLineController.php.

◆ cli_getArgIndex()

TYPO3\CMS\Core\Controller\CommandLineController::cli_getArgIndex ( array  $argv = array())

Will parse "_SERVER[argv]" into an index of options and values 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

Parameters
array$argvConfiguration options
Returns
array
Todo:
Define visibility

Definition at line 124 of file CommandLineController.php.

References TYPO3\CMS\Core\Controller\CommandLineController\$cli_options, and die.

Referenced by TYPO3\CMS\Core\Controller\CommandLineController\cli_setArguments().

◆ cli_help()

TYPO3\CMS\Core\Controller\CommandLineController::cli_help ( )

◆ cli_indent()

TYPO3\CMS\Core\Controller\CommandLineController::cli_indent (   $str,
  $indent 
)

Indentation function for 75 char wide lines.

Parameters
string$strString to break and indent.
integer$indentNumber of space chars to indent.
Returns
string Result
Todo:
Define visibility

Definition at line 296 of file CommandLineController.php.

Referenced by TYPO3\CMS\Core\Controller\CommandLineController\cli_help().

◆ cli_isArg()

TYPO3\CMS\Core\Controller\CommandLineController::cli_isArg (   $option)

◆ cli_keyboardInput()

TYPO3\CMS\Core\Controller\CommandLineController::cli_keyboardInput ( )

Asks stdin for keyboard input and returns the line (after enter is pressed)

Returns
string
Todo:
Define visibility

Definition at line 200 of file CommandLineController.php.

Referenced by TYPO3\CMS\Core\Controller\CommandLineController\cli_keyboardInput_yes().

◆ cli_keyboardInput_yes()

TYPO3\CMS\Core\Controller\CommandLineController::cli_keyboardInput_yes (   $msg = '')

Asks for Yes/No from shell and returns TRUE if "y" or "yes" is found as input.

Parameters
string$msgString to ask before...
Returns
boolean TRUE if "y" or "yes" is the input (case insensitive)
Todo:
Define visibility

Definition at line 218 of file CommandLineController.php.

References TYPO3\CMS\Core\Controller\CommandLineController\cli_keyboardInput().

Referenced by TYPO3\CMS\Lowlevel\CleanerCommand\cli_main(), and TYPO3\CMS\Lowlevel\CleanerCommand\cli_noExecutionCheck().

◆ cli_setArguments()

TYPO3\CMS\Core\Controller\CommandLineController::cli_setArguments ( array  $argv = array())

Set environment array to $cli_args

Parameters
array$argvConfiguration options
Returns
void

Definition at line 190 of file CommandLineController.php.

References TYPO3\CMS\Core\Controller\CommandLineController\cli_getArgIndex().

Referenced by TYPO3\CMS\Core\Controller\CommandLineController\__construct(), and TYPO3\CMS\Lowlevel\CleanerCommand\cli_main().

◆ cli_validateArgs()

TYPO3\CMS\Core\Controller\CommandLineController::cli_validateArgs ( )

Validates if the input arguments in this->cli_args are all listed in this->cli_options and if not, will exit with an error.

Todo:
Define visibility

Definition at line 152 of file CommandLineController.php.

References TYPO3\CMS\Core\Controller\CommandLineController\$cli_args, die, and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Lowlevel\AdminCommand\cli_main(), and TYPO3\CMS\Lowlevel\CleanerCommand\cli_main().

Member Data Documentation

◆ $cli_args

TYPO3\CMS\Core\Controller\CommandLineController::$cli_args = array()

◆ $cli_help

TYPO3\CMS\Core\Controller\CommandLineController::$cli_help
Initial value:
= array(
'name' => 'CLI base class (overwrite this...)',
'synopsis' => '###OPTIONS###',
'description' => 'Class with basic functionality for CLI scripts (overwrite this...)',
'examples' => 'Give examples...',
'options' => '',
'license' => 'GNU GPL - free software!',
'author' => '[Author name]'
)
Todo:
Define visibility

Definition at line 46 of file CommandLineController.php.

◆ $cli_options

TYPO3\CMS\Core\Controller\CommandLineController::$cli_options
Initial value:
= array(
array('-s', 'Silent operation, will only output errors and important messages.'),
array('--silent', 'Same as -s'),
array('-ss', 'Super silent, will not even output errors or important messages.')
)
Todo:
Define visibility

Definition at line 37 of file CommandLineController.php.

Referenced by TYPO3\CMS\Core\Controller\CommandLineController\cli_getArgIndex().

◆ $stdin

TYPO3\CMS\Core\Controller\CommandLineController::$stdin = NULL
Todo:
Define visibility

Definition at line 59 of file CommandLineController.php.