public function __construct($elements = array(), ArgsFormat $baseFormat = null)
{
if ($elements instanceof ArgsFormatBuilder) {
$builder = $elements;
} else {
$builder = $this->createBuilderForElements($elements, $baseFormat);
}
if (null === $baseFormat) {
$baseFormat = $builder->getBaseFormat();
}
$this->baseFormat = $baseFormat;
$this->commandNames = $builder->getCommandNames(false);
$this->arguments = $builder->getArguments(false);
$this->options = $builder->getOptions(false);
$this->hasMultiValuedArg = $builder->hasMultiValuedArgument(false);
$this->hasOptionalArg = $builder->hasOptionalArgument(false);
foreach ($this->options as $option) {
if ($option->getShortName()) {
$this->optionsByShortName[$option->getShortName()] = $option;
}
}
foreach ($builder->getCommandOptions(false) as $commandOption) {
$this->commandOptions[$commandOption->getLongName()] = $commandOption;
if ($commandOption->getShortName()) {
$this->commandOptionsByShortName[$commandOption->getShortName()] = $commandOption;
}
foreach ($commandOption->getLongAliases() as $longAlias) {
$this->commandOptions[$longAlias] = $commandOption;
}
foreach ($commandOption->getShortAliases() as $shortAlias) {
$this->commandOptionsByShortName[$shortAlias] = $commandOption;
}
}
}