|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of gpupo/netshoes-sdk |
|
5
|
|
|
* Created by Gilmar Pupo <[email protected]> |
|
6
|
|
|
* For the information of copyright and license you should read the file |
|
7
|
|
|
* LICENSE which is distributed with this source code. |
|
8
|
|
|
* Para a informação dos direitos autorais e de licença você deve ler o arquivo |
|
9
|
|
|
* LICENSE que é distribuído com este código-fonte. |
|
10
|
|
|
* Para obtener la información de los derechos de autor y la licencia debe leer |
|
11
|
|
|
* el archivo LICENSE que se distribuye con el código fuente. |
|
12
|
|
|
* For more information, see <http://www.g1mr.com/>. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Gpupo\NetshoesSdk\Console\Command; |
|
16
|
|
|
|
|
17
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
18
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
19
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @codeCoverageIgnore |
|
24
|
|
|
*/ |
|
25
|
|
|
class ScreenplayCommand extends AbstractCommand |
|
26
|
|
|
{ |
|
27
|
|
|
protected $list = ['all', 'main']; |
|
28
|
|
|
|
|
29
|
|
|
protected function screenplayList() |
|
30
|
|
|
{ |
|
31
|
|
|
return include 'screenplay.config.php'; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function all($app) |
|
35
|
|
|
{ |
|
36
|
|
|
$screenplayList = $this->screenplayList(); |
|
37
|
|
|
|
|
38
|
|
|
$this->getApp()->appendCommand('screenplay:run', 'Run all scripts') |
|
39
|
|
|
->addArgument('path', InputArgument::REQUIRED, 'Script Directory') |
|
40
|
|
|
->setCode(function (InputInterface $input, OutputInterface $output) use ($app, $screenplayList) { |
|
41
|
|
|
$path = $input->getArgument('path'); |
|
42
|
|
|
$output->writeln('Utilizando arquivos do diretório ['.$path.']'); |
|
43
|
|
|
|
|
44
|
|
|
foreach ($screenplayList as $key => $value) { |
|
45
|
|
|
$s = 'screenplay:'.$key; |
|
46
|
|
|
$command = $app->find($s); |
|
47
|
|
|
$t = new ArrayInput([ |
|
48
|
|
|
'command' => $s, |
|
49
|
|
|
'path' => $path, |
|
50
|
|
|
]); |
|
51
|
|
|
|
|
52
|
|
|
//$output->writeln('./bin/netshoes-sdk '.$s); |
|
53
|
|
|
$command->run($t, $output); |
|
54
|
|
|
} |
|
55
|
|
|
}); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function main($app) |
|
59
|
|
|
{ |
|
60
|
|
|
foreach ($this->screenplayList() as $key => $todo) { |
|
61
|
|
|
$cname = 'screenplay:'.$key; |
|
62
|
|
|
$pow = explode(':', $key); |
|
63
|
|
|
$f = current($pow); |
|
64
|
|
|
$filename = str_replace([$f.':', ':'], [$f . '/', '.'], $key).'.php'; |
|
65
|
|
|
$this->getApp()->appendCommand($cname, $todo) |
|
66
|
|
|
->addArgument('path', InputArgument::REQUIRED, 'Script Directory') |
|
67
|
|
|
->setCode(function (InputInterface $input, OutputInterface $output) use ($app, $filename, $todo, $cname) { |
|
68
|
|
|
$list = $app->processInputParameters([], $input, $output); |
|
69
|
|
|
$path = $input->getArgument('path'); |
|
70
|
|
|
|
|
71
|
|
|
$filePath = $path.$filename; |
|
72
|
|
|
$output->writeln('<options=bold>'.$todo.'</>'); |
|
73
|
|
|
|
|
74
|
|
|
if (!file_exists($filePath)) { |
|
75
|
|
|
throw new \Exception("Roteiro não implementado:" . $filePath, 1); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$sdk = $app->factorySdk($list, 'screenplay', false); |
|
79
|
|
|
|
|
80
|
|
|
$sdk->getLogger()->addDebug($cname, [ |
|
81
|
|
|
'file' => $filePath, |
|
82
|
|
|
]); |
|
83
|
|
|
|
|
84
|
|
|
$implemented = false; |
|
85
|
|
|
|
|
86
|
|
|
require $filePath; |
|
87
|
|
|
|
|
88
|
|
|
}); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|