-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUpdateComponentCommand.php
More file actions
53 lines (43 loc) · 1.24 KB
/
UpdateComponentCommand.php
File metadata and controls
53 lines (43 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Sheaf\Cli\Commands;
use Illuminate\Console\Command;
use Sheaf\Cli\Services\ComponentUpdater;
class UpdateComponentCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sheaf:update {name}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update the component if is available.';
/**
* Execute the console command.
*/
public function handle()
{
try {
$name = $this->argument('name');
$this->banner("Update component: $name");
(new ComponentUpdater($name, $this->components, $this))->handleUpdate();
return Command::SUCCESS;
} catch (\Throwable $th) {
$this->components->error('Something went wrong');
$this->components->error('Error details: ' . $th->getMessage());
}
}
public function banner(string $title): void
{
$length = strlen(" {$title}") + 4;
$this->newLine();
$this->line(str_repeat("═", $length));
$this->line(" {$title}");
$this->line(str_repeat("═", $length));
$this->newLine();
}
}