mirror of
https://github.com/anikeen-com/print-cli.git
synced 2026-03-13 13:46:07 +00:00
Remove config from git
Update packages Add list command
This commit is contained in:
50
app/Commands/ListCommand.php
Normal file
50
app/Commands/ListCommand.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user