Add autowire

Add logs command
Improve print jobs handling
Improve installation/documentation
This commit is contained in:
René Preuß
2025-07-29 22:16:32 +02:00
parent a152074975
commit 621b6cb5c0
17 changed files with 645 additions and 484 deletions

72
app/Commands/Init.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
namespace App\Commands;
use App\Traits\HasConfig;
use Illuminate\Support\Collection;
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 Init extends Command
{
use HasConfig;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'init';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a print-cli configuration file';
/**
* Execute the console command.
*/
public function handle(): void
{
$username = getenv('USER') ?: get_current_user();
$client = new Client();
$builder = new Builder();
$responseParser = new ResponseParser();
$printerManager = new PrinterManager($builder, $client, $responseParser);
$printers = Collection::make($printerManager->getList());
if ($printers->isEmpty()) {
$this->error('We could not find any printers! Setup them first :)');
return;
}
$this->info('Please register the print-server first at:');
$this->info('https://events.anikeen.com/console/resources/print-servers');
$id = $this->ask('What is your print-server ID?');
$password = $this->ask('What is your password?', match ($username) {
'print-cli' => 'print-cli',
'orangepi' => 'orangepi',
default => null,
});
$this->setConfig([
'version' => 2,
'id' => $id,
'base_url' => 'https://events.anikeen.com',
'default_credentials' => [
'username' => $username,
'password' => $password,
],
]);
}
}