本文整理汇总了PHP中Console::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::parse方法的具体用法?PHP Console::parse怎么用?PHP Console::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Console
的用法示例。
在下文中一共展示了Console::parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGet
/**
* @covers Zepto\Console::get()
*/
public function testGet()
{
$zep = new Console(array('zep', '-t', '-p'));
$zep->option('-t, --test', 'Test');
$zep->option('-p, --pest', 'Pest');
$zep->parse();
$this->assertTrue($zep->get('-t'));
$this->assertTrue($zep->get('-p'));
}
示例2: strlen
$tOptionLength = strlen($tOption);
$tUnsetKeys = [];
foreach ($uCommandParameters as $tCommandParameterKey => $tCommandParameter) {
if ($uOption[0] === Console::OPTION) {
if (strncmp($tCommandParameter, $tOption, $tOptionLength) === 0) {
$tUnsetKeys[] = $tCommandParameterKey;
$tReturn = substr($tCommandParameter, $tOptionLength);
}
} elseif ($uOption[0] === Console::OPTION_MULTIPLE) {
if (strncmp($tCommandParameter, $tOption, $tOptionLength) === 0) {
$tUnsetKeys[] = $tCommandParameterKey;
$tReturn[] = substr($tCommandParameter, $tOptionLength);
}
} elseif ($uOption[0] === Console::OPTION_FLAG) {
if (strcmp($tCommandParameter, $tOption) === 0) {
$tUnsetKeys[] = $tCommandParameterKey;
$tReturn = true;
}
}
}
foreach ($tUnsetKeys as $tUnsetKey) {
unset($uCommandParameters[$tUnsetKey]);
}
return $tReturn;
}
}
$x = new Console("EserConsole", "");
$x->addCommand("test", "Just for testing purposes...", [[Console::PARAMETER_REQUIRED, "who", ""], [Console::PARAMETER, "whom", ""], [Console::OPTION, "--flag", ""], [Console::OPTION_MULTIPLE, "--flags", ""], [Console::OPTION_FLAG, "--silent", ""]]);
echo "<pre>";
var_dump($x->parse("test \"eser ozvataf\" seyma --flag=yes --flags=a --flags=b --silent"));