Skip to content

Commit

Permalink
Merge pull request #21 from humanmade/destroy-command
Browse files Browse the repository at this point in the history
Add a destroy command
  • Loading branch information
roborourke authored May 13, 2019
2 parents bc1b17c + e0eb783 commit a38fe4d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions inc/Composer/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ protected function configure() {
start
Stop the local development server:
stop
Destroy the local development server:
destroy
View status of the local development server:
status
Run WP CLI command:
Expand All @@ -49,6 +51,8 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
return $this->stop( $input, $output );
} elseif ( $subcommand === 'restart' ) {
return $this->restart( $input, $output );
} elseif ( $subcommand === 'destroy' ) {
return $this->destroy( $input, $output );
} elseif ( $subcommand === 'cli' ) {
return $this->cli( $input, $output );
} elseif ( $subcommand === 'status' ) {
Expand Down Expand Up @@ -117,10 +121,10 @@ protected function start( InputInterface $input, OutputInterface $output ) {
protected function stop( InputInterface $input, OutputInterface $output ) {
$output->writeln( 'Stopping...' );

$proxy = new Process( 'docker-compose down', 'vendor/humanmade/local-server/docker' );
$proxy = new Process( 'docker-compose stop', 'vendor/humanmade/local-server/docker' );
$proxy->run();

$compose = new Process( 'docker-compose down', 'vendor/humanmade/local-server/docker', [
$compose = new Process( 'docker-compose stop', 'vendor/humanmade/local-server/docker', [
'VOLUME' => getcwd(),
'COMPOSE_PROJECT_NAME' => basename( getcwd() ),
] );
Expand All @@ -131,6 +135,23 @@ protected function stop( InputInterface $input, OutputInterface $output ) {
$output->writeln( 'Stopped.' );
}

protected function destroy( InputInterface $input, OutputInterface $output ) {
$output->writeln( 'Destroying...' );

$proxy = new Process( 'docker-compose down -v', 'vendor/humanmade/local-server/docker' );
$proxy->run();

$compose = new Process( 'docker-compose down -v', 'vendor/humanmade/local-server/docker', [
'VOLUME' => getcwd(),
'COMPOSE_PROJECT_NAME' => basename( getcwd() ),
] );
$compose->run( function ( $type, $buffer ) {
echo $buffer;
} );

$output->writeln( 'Destroyed.' );
}

protected function restart( InputInterface $input, OutputInterface $output ) {
$this->stop( $input, $output );
$this->start( $input, $output );
Expand Down

0 comments on commit a38fe4d

Please sign in to comment.