CHelpCommand

优质
小牛编辑
128浏览
2023-12-01
所有包 | 属性 | 方法
system.console
继承class CHelpCommand » CConsoleCommand » CComponent
源自1.0
版本$Id: CHelpCommand.php 3426 2011-10-25 00:01:09Z alexander.makarow $
源码framework/console/CHelpCommand.php
CHelpCommand代表控制台帮助命令。

CHelpCommand显示可用的命令列表或者 关于指定命令的帮助指示。

如果要使用这个命令,输入下面的命令行:
php path/to/entry_script.php help [command name]
在上面,如果没有提供命令名字,它会显示所有 可用的命令。

公共属性

隐藏继承属性

属性类型描述定义在
commandRunnerCConsoleCommandRunner命令执行对象的实例CConsoleCommand
defaultActionstring默认动作的名字。CConsoleCommand
helpstring提供命令描述。CHelpCommand
namestring命令名字。CConsoleCommand
optionHelparray提供命令帮助信息选项。CConsoleCommand

公共方法

隐藏继承方法

方法描述定义在
__call()如果类中没有调的方法名,则调用这个方法。CComponent
__construct()构造方法。CConsoleCommand
__get()返回一个属性值、一个事件处理程序列表或一个行为名称。CComponent
__isset()检查一个属性是否为null。CComponent
__set()设置一个组件的属性值。CComponent
__unset()设置一个组件的属性为null。CComponent
asa()返回这个名字的行为对象。CComponent
attachBehavior()附加一个行为到组件。CComponent
attachBehaviors()附加一个行为列表到组件。CComponent
attachEventHandler()为事件附加一个事件处理程序。CComponent
buildFileList()建立目录的文件列表。CConsoleCommand
canGetProperty()确定属性是否可读。CComponent
canSetProperty()确定属性是否可写。CComponent
confirm()通过输入y或者n来询问用户确定。CConsoleCommand
copyFiles()将文件从一个地方复制到另一个地方。CConsoleCommand
detachBehavior()从组件中分离一个行为。CComponent
detachBehaviors()从组件中分离所有行为。CComponent
detachEventHandler()分离一个存在的事件处理程序。CComponent
disableBehavior()禁用一个附加行为。CComponent
disableBehaviors()禁用组件附加的所有行为。CComponent
enableBehavior()启用一个附加行为。CComponent
enableBehaviors()启用组件附加的所有行为。CComponent
ensureDirectory()所有的父目录中如果哪个不存在,则创建它。CConsoleCommand
evaluateExpression()计算一个PHP表达式,或根据组件上下文执行回调。CComponent
getCommandRunner()返回命令执行对象的实例CConsoleCommand
getEventHandlers()返回一个事件的附加处理程序列表。CComponent
getHelp()提供命令描述。CHelpCommand
getName()返回命令名字。CConsoleCommand
getOptionHelp()提供命令帮助信息选项。CConsoleCommand
hasEvent()确定一个事件是否定义。CComponent
hasEventHandler()检查事件是否有附加的处理程序。CComponent
hasProperty()确定属性是否被定义。CComponent
init()初始化命令对象。CConsoleCommand
pluralize()将单词转换为它的复数形式。CConsoleCommand
prompt()如果readline这个PHP扩展可用,则通过它读取输入的内容,否则通过fgets()来读取。CConsoleCommand
raiseEvent()发起一个事件。CComponent
renderFile()渲染一个视图文件。CConsoleCommand
run()执行动作。CHelpCommand
usageError()显示一个运行错误。CConsoleCommand

受保护方法

隐藏继承方法

方法描述定义在
afterAction()这个方法会在一个动作执行完成后发起。CConsoleCommand
beforeAction()这个方法会在一个动作执行前发起。CConsoleCommand
resolveRequest()解析命令行参数然后决定要运行哪个动作。CConsoleCommand

属性详细

help 属性 只读 public string getHelp()

提供命令描述。

方法详细

getHelp() 方法
public string getHelp()
{return}string命令描述。
源码: framework/console/CHelpCommand.php#71 (显示) publicfunctiongetHelp()
{
returnparent::getHelp().'[command-name]';
}

提供命令描述。

run() 方法
public void run(array $args)
$argsarray指定给这个命令的命令行参数。
源码: framework/console/CHelpCommand.php#37 (显示) publicfunctionrun($args)
{
$runner=$this->getCommandRunner();
$commands=$runner->commands;
if(isset($args[0]))
$name=strtolower($args[0]);
if(!isset($args[0])||!isset($commands[$name]))
{
if(!empty($commands))
{
echo"Yiicommandrunner(basedonYiiv".Yii::getVersion().")n";
echo"Usage:".$runner->getScriptName()."<command-name>[parameters...]n";
echo"nThefollowingcommandsareavailable:n";
$commandNames=array_keys($commands);
sort($commandNames);
echo'-'.implode("n-",$commandNames);
echo"nnToseeindividualcommandhelp,usethefollowing:n";
echo"".$runner->getScriptName()."help<command-name>n";
}
else
{
echo"Noavailablecommands.n";
echo"Pleasedefinethemunderthefollowingdirectory:n";
echo"t".Yii::app()->getCommandPath()."n";
}
}
else
echo$runner->createCommand($name)->getHelp();
}

执行动作。