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

View File

@@ -34,6 +34,7 @@ The following commands have been implemented:
- docker-compose up
- docker-compose ps
- docker-compose logs
- docker-compose pull
- docker-compose exec
- docker-compose down

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;
}
}

View File

@@ -23,6 +23,14 @@ trait loadTasks
return $this->task(Ps::class, $pathToDockerCompose);
}
/**
* Docker compose logs task.
*/
protected function taskDockerComposeLogs($pathToDockerCompose = null)
{
return $this->task(Logs::class, $pathToDockerCompose);
}
/**
* Docker compose down task.
*/