Skip to content

Commit

Permalink
Merge pull request #98 from ahmed-bhs/restart-cmd
Browse files Browse the repository at this point in the history
Add Restart command
  • Loading branch information
Plopix authored Jan 22, 2021
2 parents 99f1cd7 + 3f26d94 commit d1e421c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Command/Docker/Restart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace eZ\Launchpad\Command\Docker;

use eZ\Launchpad\Core\DockerCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class Restart.
*/
final class Restart extends DockerCommand
{
protected function configure(): void
{
parent::configure();
$this->setName('docker:restart')->setDescription('Restart all the services (or just one).');
$this->addArgument('service', InputArgument::OPTIONAL, 'Service to restart', '');
$this->setAliases(['restart']);
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->dockerClient->restart($input->getArgument('service'));

return DockerCommand::SUCCESS;
}
}
5 changes: 5 additions & 0 deletions src/Core/Client/Docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public function start(string $service = '')
return $this->perform('start', $service);
}

public function restart(string $service = '')
{
return $this->perform('restart', $service);
}

public function build(array $args = [], string $service = '')
{
return $this->perform('build', $service, $args);
Expand Down
1 change: 1 addition & 0 deletions tests/Tests/Unit/DockerClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function getTestedActions(): array
['down', [['-q', '-ez']], 'down -q -ez'],
['start', ['plop'], 'start plop'],
['stop', ['plop'], 'stop plop'],
['restart', ['plop'], 'restart plop'],

['logs', [['-q', '-ez'], 'plop'], 'logs -q -ez plop'],
['up', [['-q', '-ez'], 'plop'], 'up -q -ez plop'],
Expand Down

0 comments on commit d1e421c

Please sign in to comment.