Added ability to dequeue by status

This commit is contained in:
ilumos 2017-08-17 07:44:14 +01:00
parent 2cd7bd3694
commit d6f3548ed7

View file

@ -15,7 +15,8 @@ class Dequeue extends Command
protected $signature = 'steam:dequeue
{--app_id=}
{--platform=}
{--account=}';
{--account=}
{--status=}';
/**
* The console command description.
*
@ -30,6 +31,13 @@ class Dequeue extends Command
*/
const PLATFORMS = ['windows', 'osx', 'linux'];
/**
* The permissible statuses.
*
* @var array
*/
const STATUSES = ['queued', 'completed', 'failed'];
/**
* Execute the console command.
*
@ -43,6 +51,12 @@ class Dequeue extends Command
die();
}
if( $this->option('status') && ! in_array($this->option('status'), $this::STATUSES))
{
$this->error('Invalid status specified. Available statuses are: '. implode(' ', $this::STATUSES));
die();
}
$query = Capsule::table('steam_queue');
if( $this->option('app_id') )
@ -54,6 +68,9 @@ class Dequeue extends Command
if( $this->option('account') )
$query->where('account', $this->option('account'));
if( $this->option('status') )
$query->where('status', $this->option('status'));
// If no options were specified, ask for confirmation
if( ! array_filter($this->options()) && ! $this->confirm('Are you sure you want to clear the download queue?') )
die();