ConsoleOptionParser::buildFromArray($spec)
正如前面提到的,当创建子命令选项解析器,您可以定义解析器规范作为该方法的一个数组。这可以帮助简化构建子命令的解析器,因为一切都是一个数组:$parser->addSubcommand('check', array(
'help' => __('Check the permissions between an ACO and ARO.'),
'parser' => array(
'description' => array(
__("Use this command to grant ACL permissions. Once executed, the "),
__("ARO specified (and its children, if any) will have ALLOW access "),
__("to the specified ACO action (and the ACO's children, if any).")
),
'arguments' => array(
'aro' => array('help' => __('ARO to check.'), 'required' => true),
'aco' => array('help' => __('ACO to check.'), 'required' => true),
'action' => array('help' => __('Action to check'))
)
)
));
在解析器规格,您可以定义键参数,选项,描述和跋。你不能定义子命令在一个数组风格建筑。参数的值,选择,应该遵循的格式ConsoleOptionParser::addArguments()和ConsoleOptionParser::addOptions()使用。您还可以使用buildFromArray自行建立一个选项解析器:
public function getOptionParser() {
return ConsoleOptionParser::buildFromArray(array(
'description' => array(
__("Use this command to grant ACL permissions. Once executed, the "),
__("ARO specified (and its children, if any) will have ALLOW access "),
__("to the specified ACO action (and the ACO's children, if any).")
),
'arguments' => array(
'aro' => array('help' => __('ARO to check.'), 'required' => true),
'aco' => array('help' => __('ACO to check.'), 'required' => true),
'action' => array('help' => __('Action to check'))
)
));
}