Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3fee31737 | ||
|
|
8ff8ed66bf |
@@ -33,6 +33,8 @@ composer require --dev droath/robo-docker-compose
|
|||||||
The following commands have been implemented:
|
The following commands have been implemented:
|
||||||
|
|
||||||
- docker-compose up
|
- docker-compose up
|
||||||
|
- docker-compose ps
|
||||||
|
- docker-compose logs
|
||||||
- docker-compose pull
|
- docker-compose pull
|
||||||
- docker-compose exec
|
- docker-compose exec
|
||||||
- docker-compose down
|
- docker-compose down
|
||||||
|
|||||||
77
src/Task/Logs.php
Normal file
77
src/Task/Logs.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
59
src/Task/Ps.php
Normal file
59
src/Task/Ps.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Droath\RoboDockerCompose\Task;
|
||||||
|
|
||||||
|
use Droath\RoboDockerCompose\DockerServicesTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the docker composer ps command.
|
||||||
|
*/
|
||||||
|
class Ps extends Base
|
||||||
|
{
|
||||||
|
use DockerServicesTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected $action = 'ps';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only display IDs.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function quiet()
|
||||||
|
{
|
||||||
|
$this->option('quiet');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display services.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function services()
|
||||||
|
{
|
||||||
|
$this->option('services');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter services by a property.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* The filter property key.
|
||||||
|
* @param string $value
|
||||||
|
* The filter property value.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function filter($key, $value)
|
||||||
|
{
|
||||||
|
$this->option('filter', "{$key}={$value}");
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,22 @@ trait loadTasks
|
|||||||
return $this->task(Up::class, $pathToDockerCompose);
|
return $this->task(Up::class, $pathToDockerCompose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Docker compose ps task.
|
||||||
|
*/
|
||||||
|
protected function taskDockerComposePs($pathToDockerCompose = null)
|
||||||
|
{
|
||||||
|
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.
|
* Docker compose down task.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user