static function setUpDefinition(Command\Definition $definition, $options) { $options->run = Command\Option::create()->setIsUnnamed()->setIsRequired()->setDescription('Run name')->setType(); $options->symbol = Command\Option::create()->setDescription('Function name')->setType(); $options->isInclusive = Command\Option::create()->setDescription('Show inclusive stats'); $options->limit = Option::create()->setType()->setDescription('Limit number of rows'); }
public function __construct($options) { $this->optionsArray = $options; /** @var Option $hasVariadicArgument */ $hasVariadicArgument = null; $this->optionsArray[Runner::HELP] = Option::create()->setDescription('Show usage information')->setGroup(Runner::GROUP_MISC)->setName(Runner::HELP); $this->optionsArray[Runner::VERSION] = Option::create()->setDescription('Show version')->setGroup(Runner::GROUP_MISC)->setName(Runner::VERSION); $this->optionsArray[Runner::BASH_COMPLETION] = Option::create()->setDescription('Generate bash completion')->setGroup(Runner::GROUP_MISC)->setName(Runner::BASH_COMPLETION); $this->optionsArray[Runner::INSTALL] = Option::create()->setDescription('Install to /usr/local/bin/')->setGroup(Runner::GROUP_MISC)->setName(Runner::INSTALL); foreach ($this->optionsArray as &$option) { $option = Option::cast($option); if ($option->isUnnamed) { if ($hasVariadicArgument) { throw new Exception('Non-tailing variadic argument ' . $hasVariadicArgument->getUsage(), Exception::NON_TAILING_VARIADIC_ARGUMENT); } if ($option->isVariadic) { $hasVariadicArgument = $option; } if ($option->isRequired) { if (!empty($this->optionalArguments)) { throw new Exception('Non-tailing optional argument', Exception::NON_TAILING_OPTIONAL_ARGUMENT); } $this->requiredArguments[] = $option; } else { $this->optionalArguments[] = $option; } continue; } if ($option->isRequired) { $this->requiredOptions[$option->name] = $option; } if ($option->shortName) { $this->byShortName[$option->shortName] = $option; } $this->byName[$option->getPublicName()] = $option; } }
static function setUpDefinition(Definition $definition, $options) { $options->path = Option::create()->setIsUnnamed()->setIsRequired()->setDescription('Path to profiles directory or file'); $options->alias = Option::create()->setIsUnnamed()->setDescription('Run alias name'); $options->project = Option::create()->setType()->setDescription('Project name'); $options->tags = Option::create()->setIsVariadic()->setDescription('Tags for imported data'); $options->allowDuplicates = Option::create()->setShortName('d')->setDescription('Allow duplicate profiles (by file path)'); $options->noSquash = Option::create()->setDescription('Do not combine runs into one'); $definition->name = 'xhprof-import'; $definition->description = 'XHPROF data importing tool'; $definition->version = 'v0.1'; }