Skip to content
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

Added silent flag to symfony console task #961

Merged
merged 3 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
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
22 changes: 18 additions & 4 deletions classes/phing/tasks/ext/SymfonyConsole/SymfonyConsoleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ class SymfonyConsoleTask extends Task
* @var boolean
*/
private $debug = true;


/**
* @var bool $silent
*/
private $silent = false;

/**
* sets the symfony console command to execute
* @param string $command
Expand Down Expand Up @@ -122,7 +127,6 @@ public function setCheckreturn($checkreturn)
{
$this->checkreturn = (bool) $checkreturn;
}


/**
* Whether to set the symfony cli debug mode
Expand All @@ -145,6 +149,16 @@ public function getDebug()
return $this->debug;
}

public function setSilent(bool $flag)
{
$this->silent = $flag;
}

public function getSilent()
{
return $this->silent;
}

/**
* appends an arg tag to the arguments stack
*
Expand Down Expand Up @@ -209,14 +223,14 @@ public function main()
{
$cmd = $this->getCmdString();

$this->log("executing $cmd");
$this->silent ?: $this->log("executing $cmd");
$return = null;
$output = [];
exec($cmd, $output, $return);

$lines = implode("\r\n", $output);

$this->log($lines, Project::MSG_INFO);
$this->silent ?: $this->log($lines, Project::MSG_INFO);

if ($this->propertyName != null) {
$this->project->setProperty($this->propertyName, $lines);
Expand Down
8 changes: 8 additions & 0 deletions docs/guide/en/source/appendixes/optionaltasks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13304,6 +13304,14 @@ host="webserver" command="ls" /></programlisting>
<entry>true</entry>
<entry>No</entry>
</row>
<row>
<entry>silent</entry>
<entry>Boolean</entry>
<entry>Disable task output except errors.
Use in conjunction with additional output helper like Symfonys ProgressBar</entry>
<entry>false</entry>
<entry>No</entry>
</row>
<row>
<entry>propertyName</entry>
<entry>String</entry>
Expand Down
3 changes: 3 additions & 0 deletions etc/phing-grammar.rng
Original file line number Diff line number Diff line change
Expand Up @@ -6511,6 +6511,9 @@
<attribute name="debug">
<data type="boolean"/>
</attribute>
<attribute name="silent" a:defaultValue="false">
<data type="boolean"/>
</attribute>
</optional>
<zeroOrMore>
<ref name="arg"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ public function testSetGetDebug()
$this->assertEquals(false, $o->getDebug());
}

/**
* @covers SymfonyConsoleTask::setSilent
* @covers SymfonyConsoleTask::getSilent
*/
public function testSetGetSilent()
{
$o = $this->object;
$o->setSilent(true);
$this->assertTrue($o->getSilent());
}

/**
* @covers SymfonyConsoleTask::createArg
*/
Expand Down