author | rougeronj |
Tue, 08 Sep 2015 10:31:21 +0200 | |
changeset 100 | f61bab1a115d |
parent 8 | 5a0cbbe0922a |
permissions | -rw-r--r-- |
8
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
1 |
<?php namespace Laravel\Homestead; |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
2 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
3 |
use Symfony\Component\Process\Process; |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
4 |
use Symfony\Component\Console\Command\Command; |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
5 |
use Symfony\Component\Console\Input\InputInterface; |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
6 |
use Symfony\Component\Console\Output\OutputInterface; |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
7 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
8 |
class InitCommand extends Command { |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
9 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
10 |
/** |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
11 |
* Configure the command options. |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
12 |
* |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
13 |
* @return void |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
14 |
*/ |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
15 |
protected function configure() |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
16 |
{ |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
17 |
$this->setName('init') |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
18 |
->setDescription('Create a stub Homestead.yaml file'); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
19 |
} |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
20 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
21 |
/** |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
22 |
* Execute the command. |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
23 |
* |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
24 |
* @param \Symfony\Component\Console\Input\InputInterface $input |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
25 |
* @param \Symfony\Component\Console\Output\OutputInterface $output |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
26 |
* @return void |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
27 |
*/ |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
28 |
public function execute(InputInterface $input, OutputInterface $output) |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
29 |
{ |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
30 |
if (is_dir(homestead_path())) |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
31 |
{ |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
32 |
throw new \InvalidArgumentException("Homestead has already been initialized."); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
33 |
} |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
34 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
35 |
mkdir(homestead_path()); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
36 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
37 |
copy(__DIR__.'/stubs/Homestead.yaml', homestead_path().'/Homestead.yaml'); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
38 |
copy(__DIR__.'/stubs/after.sh', homestead_path().'/after.sh'); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
39 |
copy(__DIR__.'/stubs/aliases', homestead_path().'/aliases'); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
40 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
41 |
$output->writeln('<comment>Creating Homestead.yaml file...</comment> <info>✔</info>'); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
42 |
$output->writeln('<comment>Homestead.yaml file created at:</comment> '.homestead_path().'/Homestead.yaml'); |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
43 |
} |
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
44 |
|
5a0cbbe0922a
CAS Authentication (normal and proxy) + local Homestead vm
durandn
parents:
diff
changeset
|
45 |
} |