Add the docker-compose logs command.

This commit is contained in:
Travis Tomka
2018-04-28 13:14:06 -06:00
parent 8ff8ed66bf
commit c3fee31737
3 changed files with 86 additions and 0 deletions

77
src/Task/Logs.php Normal file
View File

@@ -0,0 +1,77 @@
<?php
namespace Droath\RoboDockerCompose\Task;
use Droath\RoboDockerCompose\DockerServicesTrait;
use Robo\Exception\TaskException;
/**
* Define the docker compose logs task.
*/
class Logs extends Base
{
use DockerServicesTrait;
/**
* {@inheritdoc}
*/
protected $action = 'logs';
/**
* Produce monochrome output.
*
* @return $this
*/
public function noColor()
{
$this->option('no-color');
return $this;
}
/**
* Follow log output.
*
* @return $this
*/
public function follow()
{
$this->option('follow');
return $this;
}
/**
* Show timestamps.
*
* @return $this
*/
public function timestamps()
{
$this->option('timestamps');
return $this;
}
/**
* Number of lines to show from the end of the logs for
* each container.
*
* @param string $value
*
* @return $this
* @throws TaskException
*/
public function tail($value = 'all')
{
if ($value !== 'all' && !is_numeric($value)) {
throw new TaskException(
__CLASS__,
'Provided argument value is invalid.'
);
}
$this->option('tail', $value);
return $this;
}
}