[Command] Set the process title as late as possible

To be able to customize to process title in the `initialize`
method of the current command with some arguments or option
This commit is contained in:
Grégoire Pineau 2014-09-25 10:56:02 +02:00 committed by Fabien Potencier
parent c48ae250ac
commit 44997d35af

View File

@ -213,16 +213,6 @@ class Command
*/
public function run(InputInterface $input, OutputInterface $output)
{
if (null !== $this->processTitle) {
if (function_exists('cli_set_process_title')) {
cli_set_process_title($this->processTitle);
} elseif (function_exists('setproctitle')) {
setproctitle($this->processTitle);
} elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
$output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
}
}
// force the creation of the synopsis before the merge with the app definition
$this->getSynopsis();
@ -240,6 +230,16 @@ class Command
$this->initialize($input, $output);
if (null !== $this->processTitle) {
if (function_exists('cli_set_process_title')) {
cli_set_process_title($this->processTitle);
} elseif (function_exists('setproctitle')) {
setproctitle($this->processTitle);
} elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
$output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
}
}
if ($input->isInteractive()) {
$this->interact($input, $output);
}