8000 [Console] Added ability to set the process title by florianv · Pull Request #10471 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Added ability to set the process title #10471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Console] Added ability to set the process title
  • Loading branch information
florianv committed Mar 17, 2014
commit f9cf92b8542da837f3a8920f24d4c530052e085d
24 changes: 24 additions & 0 deletions src/Symfony/Component/Console/Application.php
8000 < 3BCB td class="blob-code blob-code-addition js-file-line"> }
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Application
private $dispatcher;
private $terminalDimensions;
private $defaultCommand;
private $processTitle = '%app% - %cmd%';

/**
* Constructor.
Expand Down Expand Up @@ -883,6 +884,15 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
$processTitle = strtr($this->processTitle, array(
'%app%' => $this->name,
'%cmd%' => $command->getName(),
));

@cli_set_process_title($processTitle);
}

foreach ($command->getHelperSet() as $helper) {
if ($helper instanceof InputAwareInterface) {
$helper->setInput($input);
Expand Down Expand Up @@ -1109,4 +1119,18 @@ public function setDefaultCommand($commandName)
{
$this->defaultCommand = $commandName;
}

/**
* Sets the process title visible in tools such as top and ps.
* The available placeholders are:
*
* - %app% This application name
* - %cmd% The running command name
*
* @param string $processTitle The process title
*/
public function setProcessTitle($processTitle)
{
$this->processTitle = $processTitle;
}
0