CConsoleCommand
| Package |
system.console |
| Inheritance |
abstract class CConsoleCommand »
CComponent |
| Subclasses |
CHelpCommand |
| Since |
1.0 |
| Version |
$Id: CConsoleCommand.php 1832 2010-02-20 03:22:45Z qiang.xue $ |
CConsoleCommand represents an executable user command.
The
run method must be implemented with the actual command execution logic.
You may override
getHelp to provide more detailed description of the command.
Property Details
commandRunner
the command runner instance
Provides the command description.
This method may be overridden to return the actual command description.
the command name.
Method Details
Constructor.
|
public array buildFileList(string $sourceDir, string $targetDir, string $baseDir='')
|
| $sourceDir |
string |
the source directory |
| $targetDir |
string |
the target directory |
| $baseDir |
string |
base directory |
| {return} |
array |
the file list (see copyFiles) |
Builds the file list of a directory.
This method traverses through the specified directory and builds
a list of files and subdirectories that the directory contains.
The result of this function can be passed to copyFiles.
|
public void copyFiles(array $fileList)
|
| $fileList |
array |
the list of files to be copied (name=>spec).
The array keys are names displayed during the copy process, and array values are specifications
for files to be copied. Each array value must be an array of the following structure:
|
Copies a list of files from one place to another.
|
public void ensureDirectory(string $directory)
|
| $directory |
string |
the directory to be checked |
Creates all parent directories if they do not exist.
getCommandRunner()
|
public string getHelp()
|
| {return} |
string |
the command description. Defaults to 'Usage: php entry-script.php command-name'. |
Provides the command description.
This method may be overridden to return the actual command description.
|
public string getName()
|
| {return} |
string |
the command name. |
|
public string pluralize(string $name)
|
| $name |
string |
the word to be pluralized |
| {return} |
string |
the pluralized word |
Converts a word to its plural form.
|
public mixed renderFile(string $_viewFile_, array $_data_=NULL, boolean $_return_=false)
|
| $_viewFile_ |
string |
view file path |
| $_data_ |
array |
optional data to be extracted as local view variables |
| $_return_ |
boolean |
whether to return the rendering result instead of displaying it |
| {return} |
mixed |
the rendering result if required. Null otherwise. |
Renders a view file.
|
abstract public void run(array $args)
|
| $args |
array |
command line parameters for this command. |
Executes the command.
|
public void usageError(string $message)
|
| $message |
string |
the error message |
Displays a usage error.
This method will then terminate the execution of the current application.