1 | <?php |
||
16 | class InfoCommand extends AbstractCommand |
||
17 | { |
||
18 | /** |
||
19 | * Configures the current command. |
||
20 | */ |
||
21 | 1 | protected function configure() |
|
28 | |||
29 | /** |
||
30 | * @return int |
||
31 | */ |
||
32 | 1 | protected function process() |
|
33 | { |
||
34 | 1 | $jobName = $this->input->getArgument('jobName'); |
|
35 | |||
36 | 1 | $chronosJobEntity = $this->checkInChronos($jobName); |
|
37 | 1 | $jobEntity = $chronosJobEntity == null ? $this->checkInMarathon($jobName) : $chronosJobEntity; |
|
38 | |||
39 | 1 | if (!$jobEntity) { |
|
40 | $this->output->writeln(sprintf('<fg=red>%s</>', 'Could not find the job.')); |
||
41 | return 1; |
||
42 | } |
||
43 | |||
44 | 1 | $this->output->writeln(sprintf("\n<comment>info '%s'</comment>\n", $jobEntity->getKey())); |
|
45 | |||
46 | 1 | $table = new Table($this->output); |
|
47 | 1 | $table->setHeaders(array('Property', 'Value')); |
|
48 | |||
49 | 1 | foreach ($jobEntity as $key => $value) { |
|
50 | 1 | if (is_array($value) || is_object($value)) { |
|
51 | 1 | $emptyString = (is_object($value)) ? '{ }' : '[ ]'; |
|
52 | |||
53 | 1 | $value = (!empty($value)) |
|
54 | ? json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) |
||
55 | 1 | : $emptyString; |
|
56 | 1 | } elseif (is_bool($value)) { |
|
57 | 1 | $value = (true === $value) |
|
58 | 1 | ? 'true' |
|
59 | 1 | : 'false'; |
|
60 | } |
||
61 | |||
62 | 1 | $table->addRow(array($key, $value)); |
|
63 | } |
||
64 | |||
65 | 1 | $table->render(); |
|
66 | |||
67 | 1 | return 0; |
|
68 | } |
||
69 | |||
70 | 1 | private function checkInChronos($jobName) |
|
76 | |||
77 | private function checkInMarathon($jobName) |
||
83 | } |
||
84 |