clrghouz/app/Console/Commands/NodelistImport.php
Deon George e15331ec35
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 40s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m43s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
No function changes. Cleanup console command cleanup
2024-05-27 15:08:39 +10:00

57 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\NodelistImport as Job;
use App\Models\File;
class NodelistImport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'nodelist:import'
.' {file : File ID | filename}'
.' {domain? : Domain Name}'
.' {--I|ignorecrc : Ignore the CRC}'
.' {--D|delete : Delete old data for the date}'
.' {--U|unlink : Delete file after import}'
.' {--T|test : Dry run}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Import Nodelist';
/**
* Execute the console command.
*
* @return int
*/
public function handle():int
{
try {
return Job::dispatchSync(
is_numeric($x=$this->argument('file'))
? File::findOrFail($x)
: sprintf('%s/%s',config('fido.dir'),$this->argument('file')),
$this->argument('domain'),
$this->option('delete'),
$this->option('unlink'),
$this->option('test'),
$this->option('ignorecrc'),
);
} catch (\Exception $e) {
$this->error($e->getMessage());
return self::FAILURE;
}
}
}