mirror of
https://github.com/anikeen-com/print-cli.git
synced 2026-03-13 13:46:07 +00:00
51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use LaravelZero\Framework\Commands\Command;
|
|
use Smalot\Cups\Builder\Builder;
|
|
use Smalot\Cups\Manager\PrinterManager;
|
|
use Smalot\Cups\Transport\Client;
|
|
use Smalot\Cups\Transport\ResponseParser;
|
|
|
|
class ListCommand extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'printers';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'List all printers';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle(): int
|
|
{
|
|
$client = new Client();
|
|
$builder = new Builder();
|
|
$responseParser = new ResponseParser();
|
|
|
|
$printerManager = new PrinterManager($builder, $client, $responseParser);
|
|
|
|
$printers = $printerManager->getList();
|
|
|
|
$this->info('Printers:');
|
|
|
|
foreach ($printers as $printer) {
|
|
$this->info($printer->getName());
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|