|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP version 7.1 |
|
4
|
|
|
* |
|
5
|
|
|
* This source file is subject to the license that is bundled with this package in the file LICENSE. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace PhUml\Console; |
|
9
|
|
|
|
|
10
|
|
|
use Exception; |
|
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
12
|
|
|
use Symfony\Component\Console\Output\StreamOutput; |
|
13
|
|
|
|
|
14
|
|
|
class UpdaterDisplay |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var OutputInterface */ |
|
17
|
|
|
private $output; |
|
18
|
|
|
|
|
19
|
27 |
|
public function __construct(OutputInterface $output = null) |
|
20
|
|
|
{ |
|
21
|
27 |
|
$this->output = $output ?? new StreamOutput(fopen('php://memory', 'w', false)); |
|
|
|
|
|
|
22
|
27 |
|
} |
|
23
|
|
|
|
|
24
|
6 |
|
public function rollbackMessage(bool $result): void |
|
25
|
|
|
{ |
|
26
|
6 |
|
if ($result) { |
|
27
|
3 |
|
$this->output->writeln('<info>phUML has been rolled back to prior version.</info>'); |
|
28
|
|
|
} else { |
|
29
|
3 |
|
$this->output->writeln('<error>Rollback failed for unknown reasons.</error>'); |
|
30
|
|
|
} |
|
31
|
6 |
|
} |
|
32
|
|
|
|
|
33
|
3 |
|
public function currentLocalVersion(string $version): void |
|
34
|
|
|
{ |
|
35
|
3 |
|
$this->output->writeln(sprintf( |
|
36
|
3 |
|
'Your current local build version is: <options=bold>%s</options=bold>', |
|
37
|
3 |
|
$version |
|
38
|
|
|
)); |
|
39
|
3 |
|
} |
|
40
|
|
|
|
|
41
|
3 |
|
public function newVersion(string $newVersion): void |
|
42
|
|
|
{ |
|
43
|
3 |
|
$this->output->writeln(sprintf( |
|
44
|
3 |
|
'The current stable build available remotely is: <options=bold>%s</options=bold>', |
|
45
|
3 |
|
$newVersion |
|
46
|
|
|
)); |
|
47
|
3 |
|
} |
|
48
|
|
|
|
|
49
|
3 |
|
public function noUpdatesAvailable(): void |
|
50
|
|
|
{ |
|
51
|
3 |
|
$this->output->writeln('There are no stable builds available.'); |
|
52
|
3 |
|
} |
|
53
|
|
|
|
|
54
|
3 |
|
public function alreadyUpToDate(): void |
|
55
|
|
|
{ |
|
56
|
3 |
|
$this->output->writeln('You have the current stable build installed.'); |
|
57
|
3 |
|
} |
|
58
|
|
|
|
|
59
|
3 |
|
public function updateApplied(string $oldVersion, string $newVersion): void |
|
60
|
|
|
{ |
|
61
|
3 |
|
$this->output->writeln('<info>phUML has been updated.</info>'); |
|
62
|
3 |
|
$this->output->writeln(sprintf( |
|
63
|
3 |
|
'<info>Current version is:</info> <options=bold>%s</options=bold>.', |
|
64
|
3 |
|
$newVersion |
|
65
|
|
|
)); |
|
66
|
3 |
|
$this->output->writeln(sprintf( |
|
67
|
3 |
|
'<info>Previous version was:</info> <options=bold>%s</options=bold>.', |
|
68
|
3 |
|
$oldVersion |
|
69
|
|
|
)); |
|
70
|
3 |
|
} |
|
71
|
|
|
|
|
72
|
3 |
|
public function noUpdateApplied(string $currentVersion): void |
|
73
|
|
|
{ |
|
74
|
3 |
|
$this->output->writeln('<info>phUML is currently up to date.</info>'); |
|
75
|
3 |
|
$this->output->writeln(sprintf( |
|
76
|
3 |
|
'<info>Current version is:</info> <options=bold>%s</options=bold>.', |
|
77
|
3 |
|
$currentVersion |
|
78
|
|
|
)); |
|
79
|
3 |
|
} |
|
80
|
|
|
|
|
81
|
3 |
|
public function error(Exception $exception): void |
|
82
|
|
|
{ |
|
83
|
3 |
|
$this->output->writeln(sprintf('Error: <comment>%s</comment>', $exception->getMessage())); |
|
84
|
3 |
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|