blob: 8a6a8e7b8ee63c83b14b445fefa565c9343930ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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');
}
}
|