本文整理匯總了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"));