diff options
Diffstat (limited to 'src/Script/Command/Site.php')
-rw-r--r-- | src/Script/Command/Site.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/Script/Command/Site.php b/src/Script/Command/Site.php new file mode 100644 index 0000000..8a6a8e7 --- /dev/null +++ b/src/Script/Command/Site.php @@ -0,0 +1,80 @@ +<?php + +namespace App\Script\Command; + +use Symfony\Component\Console\Command\Command as SyCommand; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Helper\ProgressBar; +use App\Filesystem\CreateFile; +use App\Filesystem\CreateDirectory; + +class Site extends SyCommand +{ + protected function configure() + { + $this + ->addArgument('name', InputArgument::REQUIRED, 'The name of the new site.'); + + $this + ->addArgument('domain', InputArgument::REQUIRED, 'The domain name of the new site.'); + + $this + ->setName('site:create') + ->setDescription('Create a new site.') + ->setHelp('This command allows you to create a new site.') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $taskCount = 6; + $output->writeln( + 'Creating new site with domain: ' + . $input->getArgument('domain') + . ' and name: ' + . $input->getArgument('name') + ); + + $progressBar = new ProgressBar($output, $taskCount); + $progressBar->setFormatDefinition('custom', ' %current%/%max% -- %message%'); + $progressBar->setFormat('custom'); + $progressBar->setMessage('Starting...'); + $progressBar->start(); + $progressBar->setMessage('Running pre-flight checks'); + + $progressBar->advance(); + try { + $create = new \App\Filesystem\CreateFile(DIPPER_ROOT . '/foo.test'); + $create = new \App\Filesystem\CreateDirectory(DIPPER_ROOT); + sleep(1); + } catch (\Exception $e) { + $output->writeln('Error with pre-flight checks'); + $output->writeln($e->getMessage()); + exit; + } + + $progressBar->advance(); + $progressBar->setMessage('Creating directory structure'); + sleep(1); + + $progressBar->advance(); + $progressBar->setMessage('Creating nginx config'); + sleep(1); + + $progressBar->advance(); + $progressBar->setMessage('Creating default index.php'); + sleep(1); + + $progressBar->advance(); + $progressBar->setMessage('Creating nginx config'); + sleep(1); + + $progressBar->advance(); + $progressBar->finish(); + + $output->writeln(''); + $output->writeln('Complete'); + } +} |