Skip to content

Commit

Permalink
Add task confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
kilrizzy committed Jul 9, 2017
1 parent 8696aba commit ec28571
Showing 1 changed file with 44 additions and 14 deletions.
58 changes: 44 additions & 14 deletions app/Commands/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,34 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->domain = $this->getDomainFromQuestion();

if($this->useComposer && !empty($this->composerProject)){
$output->writeln('<info>Creating project..</info>');
$this->createProject();
}
$taskConfirmation = $this->getTaskConfirmationFromQuestion();

if($taskConfirmation){

if($this->useComposer && !empty($this->composerProject)){
$output->writeln('<info>Creating project..</info>');
$this->createProject();
}

$output->writeln('<info>Create host ('.$this->domain.')...</info>');
$this->updateHostsFile();
$output->writeln('<info>Create host ('.$this->domain.')...</info>');
$this->updateHostsFile();

$output->writeln('<info>Update Vagrant site mapper ('.$this->folder.')</info>');
$this->updateHomesteadSites();
$output->writeln('<info>Update Vagrant site mapper ('.$this->folder.')</info>');
$this->updateHomesteadSites();

$output->writeln('<info>Update Vagrant database ('.$this->database.')</info>');
$this->updateHomesteadDatabases();
$output->writeln('<info>Update Vagrant database ('.$this->database.')</info>');
$this->updateHomesteadDatabases();

$output->writeln('<info>Provision Vagrant</info>');
$this->provisionHomestead();
$output->writeln('<info>Provision Vagrant</info>');
$this->provisionHomestead();

$output->writeln('<success>Complete!</success>');
$output->writeln('<success>Complete!</success>');

$output->writeln('Visit: http://' . $this->domain);
$output->writeln('Visit: http://' . $this->domain);

}else{
$output->writeln('<error>Tasks cancelled</error>');
}

return;

Expand Down Expand Up @@ -137,6 +145,28 @@ private function getDomainFromQuestion(){
return $this->questionHelper->ask($this->inputInterface, $this->outputInterface, $question);
}

private function getTaskConfirmationFromQuestion(){
$this->outputInterface->writeln('<info>The following tasks will be executed:</info>');
if($this->useComposer && !empty($this->composerProject)){
$this->outputInterface->writeln("- Run Command: cd {$this->folder} && composer create-project {$this->composerProject} {$this->name}");
}
$this->outputInterface->writeln('- ('.$this->hostPath.') add line: '.$this->hostIP.' '.$this->domain);
$this->outputInterface->writeln('- ('.$this->homesteadPath.') map : '.$this->domain.' to '.$this->homesteadSitesPath.$this->name.$this->folderSuffix);
$this->outputInterface->writeln('- ('.$this->homesteadPath.') add to databases: '.$this->database);
if(!empty($this->homesteadProvisionCommand)){
$this->outputInterface->writeln('- Run Command: '.$this->homesteadProvisionCommand);
}else{
$this->outputInterface->writeln('- Run Command: cd '.$this->homesteadBoxPath.' && vagrant provision');
}
$default = 'Y';
$question = new Question('Run tasks? ('.$default.'): ', $default);
$response = $this->questionHelper->ask($this->inputInterface, $this->outputInterface, $question);
if(strtoupper($response) == 'Y'){
return true;
}
return false;
}

private function defaultDatabaseNameFromKey($key){
$key = strtolower($key);
$key = str_replace(' ','-',$key);
Expand Down

0 comments on commit ec28571

Please sign in to comment.