TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Controller\CommandLineController Class Reference
Inheritance diagram for TYPO3\CMS\Core\Controller\CommandLineController:
TYPO3\CMS\Lowlevel\AdminCommand TYPO3\CMS\Lowlevel\CleanerCommand 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=[])
 
 cli_validateArgs ()
 
 cli_setArguments (array $argv=[])
 
 cli_keyboardInput ()
 
 cli_keyboardInput_yes ($msg='')
 
 cli_echo ($string='', $force=false)
 
 cli_help ()
 
 cli_indent ($str, $indent)
 

Public Attributes

 $cli_args = []
 
 $cli_options
 
 $cli_help
 
 $stdin = null
 

Detailed Description

TYPO3 cli script basis

Definition at line 20 of file CommandLineController.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor Make sure child classes also call this!

Returns
void

Definition at line 62 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
bool$forceIf string should be written even if -s is set (-ss will subdue it!)
Returns
bool Returns TRUE if string was outputted.

Definition at line 227 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.

Definition at line 76 of file CommandLineController.php.

◆ cli_getArgIndex()

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

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

Definition at line 118 of file CommandLineController.php.

References TYPO3\CMS\Core\Controller\CommandLineController\$cli_options.

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

◆ 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.
int$indentNumber of space chars to indent.
Returns
string Result

Definition at line 290 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

Definition at line 195 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
bool TRUE if "y" or "yes" is the input (case insensitive)

Definition at line 212 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 = [])

Set environment array to $cli_args

Parameters
array$argvConfiguration options
Returns
void

Definition at line 185 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.

Definition at line 146 of file CommandLineController.php.

References TYPO3\CMS\Core\Controller\CommandLineController\$cli_args, 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 = []

◆ $cli_help

TYPO3\CMS\Core\Controller\CommandLineController::$cli_help
Initial value:
= [
'name' => 'CLI base class (overwrite this...)'

Definition at line 41 of file CommandLineController.php.

◆ $cli_options

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

Definition at line 32 of file CommandLineController.php.

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

◆ $stdin

TYPO3\CMS\Core\Controller\CommandLineController::$stdin = null

Definition at line 54 of file CommandLineController.php.