For options with values, you can pass the value in the second argument.
The value is converted to the type defined by the argument format.
For options without values, you can omit the second argument. Optionally,
you can pass true/false explicitly to enable/disable the option.
/** * Creates the arguments from the current class state. * * @param ArgsFormat $format The format. * @param RawArgs $rawArgs The raw arguments. * * @return Args The created console arguments. */ private function createArgs(ArgsFormat $format, RawArgs $rawArgs) { $args = new Args($format, $rawArgs); foreach ($this->arguments as $name => $value) { // Filter command names if ($format->hasArgument($name)) { $args->setArgument($name, $value); } } foreach ($this->options as $name => $value) { // Filter command options if ($format->hasOption($name)) { $args->setOption($name, $value); } } return $args; }
/** * {@inheritdoc} */ public function setOption($name, $value) { if ($this->args) { $this->args->setOption($name, $value); } }
public function testIsOptionSetReturnsFalseAfterSettingToFalse() { $format = ArgsFormat::build()->addOption(new Option('option'))->getFormat(); $args = new Args($format); $args->setOption('option'); $args->setOption('option', false); $this->assertFalse($args->isOptionSet('option')); }