69 throw new \LogicException(sprintf(
'The command defined in "%s" cannot have an empty name.', get_class($this)));
96 $this->helperSet = null;
171 throw new \LogicException(
'You must override the execute() method in the concrete command class.');
231 $input->
bind($this->definition);
232 }
catch (\Exception $e) {
240 if (null !== $this->processTitle) {
241 if (function_exists(
'cli_set_process_title')) {
242 cli_set_process_title($this->processTitle);
243 }
elseif (function_exists(
'setproctitle')) {
244 setproctitle($this->processTitle);
246 $output->
writeln(
'<comment>Install the proctitle PECL to be able to change the process title.</comment>');
257 $statusCode = call_user_func($this->code, $input, $output);
259 $statusCode = $this->
execute($input, $output);
262 return is_numeric($statusCode) ? (int) $statusCode : 0;
283 if (!is_callable(
$code)) {
284 throw new \InvalidArgumentException(
'Invalid callable provided to Command::setCode.');
301 if (null === $this->application || (
true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
306 $currentArguments = $this->definition->getArguments();
307 $this->definition->setArguments($this->application->getDefinition()->getArguments());
308 $this->definition->addArguments($currentArguments);
311 $this->definition->addOptions($this->application->getDefinition()->getOptions());
313 $this->applicationDefinitionMerged =
true;
315 $this->applicationDefinitionMergedWithArgs =
true;
336 $this->applicationDefinitionMerged =
false;
446 $this->processTitle = $title;
529 $placeholders = array(
531 '%command.full_name%',
533 $replacements = array(
535 $_SERVER[
'PHP_SELF'].
' '.
$name,
538 return str_replace($placeholders, $replacements, $this->
getHelp());
555 throw new \InvalidArgumentException(
'$aliases must be an array or an instance of \Traversable');
588 $key = $short ?
'short' :
'long';
590 if (!isset($this->synopsis[$key])) {
591 $this->synopsis[$key] = trim(sprintf(
'%s %s', $this->name, $this->definition->getSynopsis($short)));
594 return $this->synopsis[$key];
604 if (0 !== strpos($usage, $this->name)) {
605 $usage = sprintf(
'%s %s', $this->name, $usage);
608 $this->usages[] = $usage;
636 return $this->helperSet->get(
$name);
648 @trigger_error(
'The '.__METHOD__.
' method is deprecated since version 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
652 $descriptor->describe($output, $this, array(
'raw_output' =>
true));
654 return $output->fetch();
666 public function asXml($asDom =
false)
668 @trigger_error(
'The '.__METHOD__.
' method is deprecated since version 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
673 return $descriptor->getCommandDocument($this);
677 $descriptor->describe($output, $this);
679 return $output->fetch();
693 if (!preg_match(
'/^[^\:]++(\:[^\:]++)*$/',
$name)) {
694 throw new \InvalidArgumentException(sprintf(
'Command name "%s" is invalid.',
$name));