Move ANSI* commands to BBS/
This commit is contained in:
parent
c9688ef373
commit
2dd7a6ebd3
37
app/Console/Commands/BBS/ANSIDecode.php
Normal file
37
app/Console/Commands/BBS/ANSIDecode.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\BBS;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Classes\ANSI;
|
||||||
|
|
||||||
|
class ANSIDecode extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'bbs:ansi:decode'
|
||||||
|
.' {file : ANS file to decode}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Decode ANS file from custom binary';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
echo ANSI::ansi($this->argument('file'));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
42
app/Console/Commands/BBS/ANSIEncode.php
Normal file
42
app/Console/Commands/BBS/ANSIEncode.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\BBS;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
use App\Classes\ANSI;
|
||||||
|
|
||||||
|
class ANSIEncode extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'bbs:ansi:encode'
|
||||||
|
.' {file : ANS file to encode}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Encode ANS file to custom binary';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
foreach (ANSI::binary($this->argument('file')) as $line) {
|
||||||
|
foreach (str_split(bin2hex($line),2) as $y)
|
||||||
|
echo hex2bin($y);
|
||||||
|
|
||||||
|
echo "\r";
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
53
app/Console/Commands/BBS/FrameDelete.php
Normal file
53
app/Console/Commands/BBS/FrameDelete.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\BBS;
|
||||||
|
|
||||||
|
use App\Models\Frame;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class FrameDelete extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'bbs:frame:delete {frame} {index}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Delete frames from the database.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
if (! is_numeric($this->argument('frame')))
|
||||||
|
throw new \Exception('Frame is not numeric: '.$this->argument('frame'));
|
||||||
|
|
||||||
|
if (strlen($this->argument('index')) != 1 OR ! preg_match('/^[a-z]$/',$this->argument('index')))
|
||||||
|
throw new \Exception('Subframe failed validation');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$o = Frame::where('frame',$this->argument('frame'))
|
||||||
|
->where('index',$this->argument('index'))
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
} catch (ModelNotFoundException $e) {
|
||||||
|
$this->error('Page not found to delete: '.$this->argument('frame').$this->argument('index'));
|
||||||
|
die(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$o->delete();
|
||||||
|
$this->info('Page deleted: '.$this->argument('frame').$this->argument('index'));
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ class FrameImport extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'frame:import {frame} {file} '.
|
protected $signature = 'bbs:frame:import {frame} {file} '.
|
||||||
'{--index=a : The frame index }'.
|
'{--index=a : The frame index }'.
|
||||||
'{--access=0 : Is frame accessible }'.
|
'{--access=0 : Is frame accessible }'.
|
||||||
'{--public=0 : Is frame limited to CUG }'.
|
'{--public=0 : Is frame limited to CUG }'.
|
||||||
|
Loading…
Reference in New Issue
Block a user