/** * @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')); }
$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"));