SilverCart\Dev\Tasks\Task
Basic task functionallity to handle cli args.
- Author: Sebastian Diel <sdiel@pixeltricks.de>
- Copyright: 2018 pixeltricks GmbH
- License: see license file in modules root directory
Synopsis
class Task
extends CliController
{
- // methods
- protected mixed init()
- // Inherited methods from CLITask
- public static array getRunningActions()
- protected static string getRunningTaskActionFilename()
- public static void removeTaskActionFile()
- public static void removeActionFilename()
- protected void initArgs()
- protected array getHelpDocs()
- public void help()
- public void helpNoAction()
- protected string getRunningActionFilename()
- protected void exitIfRunningAction()
- public void finishRunningActionOnBeforeExit()
- public bool isRunningAction()
- public void finishAction()
- public int getRunningActionStartTime()
- public bool isRunningCLI()
- public string getHTMLColor()
- public string getHTMLBgColor()
- public void printErrors()
- public void printInfos()
- public void printError()
- public void printInfo()
- public void printString()
- public void printProgressInfo()
- public void printProgressPercentageInfo()
- public void printProgressPercentageInfoWithTime()
- public void printMemoryInfo()
- public void printMemoryProgressInfo()
- public int printStartTime()
- public void printEndTime()
- public void loginSimulation()
- public bool isInSilentMode()
- public void setCliArg()
- public mixed getCliArg()
- public static string getTmpFolder()
- public static void setTmpFolder()
- protected void setLogFileNamePrefix()
- protected void setLogFileNameSuffix()
- public void Log()
- public string getXofY()
- protected array getFilesInDirectory()
- protected void extractZipFile()
- protected void deleteFiles()
- public static void add_error()
- public static array get_errors()
- public static void set_errors()
- public static void add_info()
- public static array get_infos()
- public static void set_infos()
- protected static string run_process_in_background()
- protected static bool is_process_running()
- public void addEmailInfo()
- public void addEmailError()
- public void addEmailWarning()
- public void sendEmail()
Hierarchy
Members
protected
- $default_help_docs
—
array
Help docs. - $emailInfos
—
array
List of infos to send by email. - $errors
—
array
List of occured errors - $finishRunningActionsOnBeforeExit
—
array
List of action callbacks to finish before self::exitIfRunningAction() is calling exit(). - $infos
—
array
List of occured infos - $lastProgressInfoLength
—
int
Contains the length of the last progress string printed by $this->printProgressInfo() - $log_file_name
—
string
Optional log file name. - $tmpFolder
—
string
Folder for temporary files
public
- $CLI_COLOR_BLACK
- $CLI_COLOR_BLUE
- $CLI_COLOR_CHANGE_BLACK
- $CLI_COLOR_CHANGE_BLUE
- $CLI_COLOR_CHANGE_CYAN
- $CLI_COLOR_CHANGE_GREEN
- $CLI_COLOR_CHANGE_MAGENTA
- $CLI_COLOR_CHANGE_RED
- $CLI_COLOR_CHANGE_WHITE
- $CLI_COLOR_CHANGE_YELLOW
- $CLI_COLOR_CYAN
- $CLI_COLOR_GREEN
- $CLI_COLOR_MAGENTA
- $CLI_COLOR_RED
- $CLI_COLOR_WHITE
- $CLI_COLOR_YELLOW
- $CLI_EMAIL_INFO_TYPE_ERROR
- $CLI_EMAIL_INFO_TYPE_INFO
- $CLI_EMAIL_INFO_TYPE_WARNING
- $RUNNING_ACTION_FILE_PREFIX
- $cli_args
—
array
Default CLI arguments
Methods
protected
- init() — Init
Inherited from SilverCart\Dev\CLITask
protected
- deleteFiles() — Deletes all files with the given extension out of the given directory.
- exitIfRunningAction() — Will exit the currently running program if the requested $action is already running. If $markAsStarted is set to true, the $action will automatically be marked as started if not running yet. If $printInfoMessage is set to false, nothing will be printed to the output.
- extractZipFile() — Extracts the given ZIP file into the given target folder.
- getFilesInDirectory() — Returns an array with all filepaths of the given file types in the given directory.
- getHelpDocs() — Returns the help docs.
- getRunningActionFilename() — Returns the file name (including path) for the running action.
- getRunningTaskActionFilename() — Returns the file name (including path) for the running $action of the given $task.
- initArgs() — Initializes the given arguments.
- is_process_running() — Checks whether a process with the given PID is running
- run_process_in_background() — Runs a command in background and returns its PID
- setLogFileNamePrefix() — Adds the given prefix to the log file name (separated with a ".").
- setLogFileNameSuffix() — Adds the given suffix to the log file name (separated with a ".").
public
- Log() — Writes a log entry
- addEmailError() — Adds an error message to send by email after the task is done.
- addEmailInfo() — Adds an information to send by email after the task is done.
- addEmailWarning() — Adds an warning message to send by email after the task is done.
- add_error() — Adds an error to the errors list
- add_info() — Adds an info to the infos list
- finishAction() — Will mark the requested $action as finished by removing the file marker.
- finishRunningActionOnBeforeExit() — Adds the given $action and $task combination to the callback list.
- getCliArg() — Returns the CLI argument with the given name
- getHTMLBgColor() — Returns the matching HTML color code to use as background color for the given CLI color code.
- getHTMLColor() — Returns the HTML color code for the given CLI color code.
- getRunningActionStartTime() — Returns the start time for the requested $action (if running).
- getRunningActions() — Returns a list of running actions.
- getTmpFolder() — Returns the folder for temporary files.
- getXofY() — Returns a padded X of Y string.
- get_errors() — Returns the errors
- get_infos() — Returns the infos
- help() — Will show the help.
- helpNoAction() — Will show the help.
- isInSilentMode() — Returns whether the task is in silent mode or not
- isRunningAction() — Checks whether the requested $action is already running. If $markAsStarted is set to true, the $action will automatically be marked as started if not running yet.
- isRunningCLI() — Returns whether the current task is running in CLI.
- loginSimulation() — Simulates a login by setting the session param for the logged in user ID
- printEndTime() — Prints end time information to the output.
- printError() — Prints the given error
- printErrors() — Prints the errors
- printInfo() — Prints the given info Colors: <ul> <li>30 -> black</li> <li>31 -> red</li> <li>32 -> green</li> <li>33 -> yellow</li> <li>34 -> blue</li> <li>35 -> magenta</li> <li>36 -> cyan</li> <li>37 -> white</li> </ul>
- printInfos() — Prints the infos
- printMemoryInfo() — Prints the current memory usage.
- printMemoryProgressInfo() — Prints the current memory usage as progress.
- printProgressInfo() — Prints the given progess info.
- printProgressPercentageInfo() — Prints the progress percentage info
- printProgressPercentageInfoWithTime() — Prints the progress percentage info
- printStartTime() — Prints the current time as start time and returns the timestamp.
- printString() — Prints and logs the given string.
- removeActionFilename() — Removes the file with the given $filename.
- removeTaskActionFile() — Removes the running $action file for the given $task.
- sendEmail() — Send the information email to the given $recipient.
- setCliArg() — Sets the CLI argument with the given name
- setTmpFolder() — Sets the folder for temporary files
- set_errors() — Sets the errors
- set_infos() — Sets the infos