mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Jobs\FirmwarePollJob;
|
|
use App\Models\Firmware;
|
|
use Illuminate\Console\Command;
|
|
|
|
use function Laravel\Prompts\spin;
|
|
use function Laravel\Prompts\table;
|
|
|
|
class FirmwareCheckCommand extends Command
|
|
{
|
|
protected $signature = 'trmnl:firmware:check {--download : Download the latest firmware if available}';
|
|
|
|
protected $description = 'Checks for the latest firmware and downloads it if flag --download is passed.';
|
|
|
|
public function handle(): void
|
|
{
|
|
spin(
|
|
callback: fn () => FirmwarePollJob::dispatchSync(download: $this->option('download')),
|
|
message: 'Checking for latest firmware...'
|
|
);
|
|
|
|
$latestFirmware = Firmware::getLatest();
|
|
if ($latestFirmware instanceof Firmware) {
|
|
table(
|
|
rows: [
|
|
['Latest Version', $latestFirmware->version_tag],
|
|
['Download URL', $latestFirmware->url],
|
|
['Storage Location', $latestFirmware->storage_location],
|
|
]
|
|
);
|
|
} else {
|
|
$this->error('No firmware found.');
|
|
}
|
|
}
|
|
}
|