TYPO3  7.6
Public Member Functions | Public Attributes | List of all members
CommandLineController Class Reference
Inheritance diagram for CommandLineController:
AdminCommand CleanerCommand CleanFlexformCommand DeletedRecordsCommand DoubleFilesCommand LostFilesCommand MissingFilesCommand MissingRelationsCommand OrphanRecordsCommand RteImagesCommand SyslogCommand 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

TYPO3 cli script basis

Definition at line 20 of file CommandLineController.php.

Constructor & Destructor Documentation

__construct ( )

Constructor Make sure child classes also call this!

Returns
void

Definition at line 62 of file CommandLineController.php.

References CommandLineController\cli_setArguments().

Member Function Documentation

cli_argValue (   $option,
  $idx = 0 
)

Return argument value

Parameters
string$optionOption string, eg. "-s
int$idxValue index, default is 0 (zero) = the first one...
Returns
bool TRUE if option found

Definition at line 105 of file CommandLineController.php.

Referenced by AdminCommand\cli_main(), CleanFlexformCommand\main(), DeletedRecordsCommand\main(), VersionsCommand\main(), OrphanRecordsCommand\main(), and LostFilesCommand\main().

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 226 of file CommandLineController.php.

References elseif.

Referenced by CommandLineController\cli_help(), AdminCommand\cli_main(), and CleanerCommand\cli_main().

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 ( 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

Definition at line 118 of file CommandLineController.php.

References CommandLineController\$cli_options.

Referenced by CommandLineController\cli_setArguments().

cli_help ( )
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 289 of file CommandLineController.php.

Referenced by CommandLineController\cli_help().

cli_isArg (   $option)

Return TRUE if option is found

Parameters
string$optionOption string, eg. "-s
Returns
bool TRUE if option found

Definition at line 93 of file CommandLineController.php.

Referenced by CleanerCommand\cli_main(), CleanFlexformCommand\main(), DeletedRecordsCommand\main(), VersionsCommand\main(), and VersionsCommand\main_autoFix().

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 CommandLineController\cli_keyboardInput_yes().

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 CommandLineController\cli_keyboardInput().

Referenced by CleanerCommand\cli_main().

cli_setArguments ( array  $argv = array())

Set environment array to $cli_args

Parameters
array$argvConfiguration options
Returns
void

Definition at line 185 of file CommandLineController.php.

References CommandLineController\cli_getArgIndex().

Referenced by CommandLineController\__construct(), and CleanerCommand\cli_main().

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 CommandLineController\$cli_args.

Referenced by AdminCommand\cli_main(), and CleanerCommand\cli_main().

Member Data Documentation

$cli_args = array()

Definition at line 27 of file CommandLineController.php.

Referenced by CommandLineController\cli_validateArgs().

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]'
)

Definition at line 41 of file CommandLineController.php.

$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.')
)

Definition at line 32 of file CommandLineController.php.

Referenced by CommandLineController\cli_getArgIndex().

$stdin = null

Definition at line 54 of file CommandLineController.php.