Skip to content

Commit e87b652

Browse files
committed
CLI design improvement
1 parent 21b3811 commit e87b652

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/Cli/BrefSpinner.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class BrefSpinner
3939
];
4040
private int $startTime;
4141
private string $message;
42-
private int $currentFrame = 0;
42+
private ?string $extraMessage = null;
43+
private int $currentFrame = 7;
4344
private bool $started = true;
4445
private string $timerId;
4546
private ?Cursor $cursor;
@@ -81,7 +82,7 @@ public function advance(): void
8182
/**
8283
* Finish the indicator with message.
8384
*/
84-
public function finish(string $message): void
85+
public function finish(string $message, ?string $extraMessage = null): void
8586
{
8687
if (! $this->started) throw new LogicException('Progress indicator has not yet been started.');
8788

@@ -91,6 +92,7 @@ public function finish(string $message): void
9192

9293
$this->currentFrame = 5;
9394
$this->message = $message;
95+
$this->extraMessage = $extraMessage;
9496
$this->render();
9597
$this->output->writeln('');
9698
$this->started = false;
@@ -114,7 +116,13 @@ public function render(): void
114116
$frame = Styles::blue('');
115117
}
116118

117-
$line = ' ' . $frame . ' ' . $this->message . Styles::gray('' . $this->formatTime(time() - $this->startTime));
119+
$timeFormatted = $this->formatTime(time() - $this->startTime);
120+
if ($this->extraMessage) {
121+
// Finished with success
122+
$line = Styles::gray($timeFormatted . '') . $this->message . Styles::gray('') . $this->extraMessage;
123+
} else {
124+
$line = ' ' . $frame . ' ' . $this->message . Styles::gray('' . $timeFormatted);
125+
}
118126
$this->overwrite($line);
119127

120128
$this->previousMessage = $this->message;

src/Cli/IO.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ public static function spinError(string $message = 'error'): void
138138
self::$spinner = null;
139139
}
140140

141-
public static function spinSuccess(string $message): void
141+
public static function spinSuccess(string $message, ?string $extraMessage = null): void
142142
{
143-
self::$spinner?->finish($message);
143+
self::$spinner?->finish($message, $extraMessage);
144144
self::$spinner = null;
145145
}
146146

src/Commands/Deploy.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
use Bref\Cli\Cli\Styles;
1717
use Bref\Cli\Components\ServerlessFramework;
1818
use Exception;
19-
use Revolt\EventLoop;
2019
use Symfony\Component\Console\Input\InputInterface;
2120
use Symfony\Component\Console\Input\InputOption;
2221
use Symfony\Component\Console\Output\OutputInterface;
2322
use Symfony\Component\Console\Question\ChoiceQuestion;
24-
use Symfony\Component\HttpClient\HttpClient;
2523
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
2624
use Throwable;
2725
use ZipArchive;
@@ -57,7 +55,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5755

5856
IO::writeln([
5957
sprintf("Deploying %s to environment %s", Styles::bold($appName), Styles::bold($environment)),
60-
'',
6158
]);
6259

6360
IO::spin('creating deployment');
@@ -154,13 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
154151
while (time() - $startTime < 15 * 60) {
155152
$deployment = $brefCloud->getDeployment($deploymentId);
156153
if ($deployment['status'] === 'success') {
157-
IO::spinSuccess($deployment['message']);
158-
if ($deployment['outputs'] ?? null) {
159-
IO::writeln('');
160-
foreach ($deployment['outputs'] as $key => $value) {
161-
IO::writeln("$key: $value");
162-
}
163-
}
154+
IO::spinSuccess($deployment['message'], $deployment['app_url'] ?? null);
164155
return 0;
165156
}
166157
if ($deployment['status'] === 'failed') {

0 commit comments

Comments
 (0)