Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions app/Commands/ApplicationList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class ApplicationList extends BaseCommand
{
Expand All @@ -28,14 +27,12 @@ public function handle()
'Fetching applications...',
)->collect();

$this->outputJsonIfWanted($applications);

if ($applications->isEmpty()) {
warning('No applications found.');

return self::FAILURE;
$this->failAndExit('No applications found.');
}

$this->outputJsonIfWanted($applications);

dataTable(
headers: ['ID', 'Name', 'Region', 'Repository'],
rows: $applications->map(fn (Application $app) => [
Expand Down
52 changes: 26 additions & 26 deletions app/Commands/BackgroundProcessCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function createBackgroundProcess(EnvironmentInstance $instance)
'timeout',
'force',
])->mapWithKeys(fn ($key) => [
$key => $this->form()->get('config.'.$key, $this->getWorkerDefult($key)),
$key => $this->form()->get('config.'.$key, $this->getWorkerDefault($key)),
])->toArray();
} else {
$command = $this->form()->get('command');
Expand All @@ -131,10 +131,10 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => text(
label: 'Connection',
default: $value ?? $this->getWorkerDefult('connection'),
default: $value ?? $this->getWorkerDefault('connection'),
required: true,
))
->nonInteractively(fn () => $this->getWorkerDefult('connection'))
->nonInteractively(fn () => $this->getWorkerDefault('connection'))
->shouldPromptOnce(),
'connection',
);
Expand All @@ -144,11 +144,11 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => text(
label: 'Queue',
default: $value ?? $this->getWorkerDefult('queue'),
default: $value ?? $this->getWorkerDefault('queue'),
required: true,
hint: 'Comma-separated for multiple queues',
))
->nonInteractively(fn () => $this->getWorkerDefult('queue'))
->nonInteractively(fn () => $this->getWorkerDefault('queue'))
->shouldPromptOnce(),
'queue',
);
Expand All @@ -158,11 +158,11 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => number(
label: 'Tries',
default: $value ?? $this->getWorkerDefult('tries'),
default: $value ?? $this->getWorkerDefault('tries'),
required: true,
hint: 'Number of times a job should be attempted',
))
->nonInteractively(fn () => $this->getWorkerDefult('tries'))
->nonInteractively(fn () => $this->getWorkerDefault('tries'))
->shouldPromptOnce(),
'tries',
);
Expand All @@ -172,11 +172,11 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => number(
label: 'Backoff',
default: $value ?? $this->getWorkerDefult('backoff'),
default: $value ?? $this->getWorkerDefault('backoff'),
required: true,
hint: 'Number of seconds to wait before retrying a failed job.',
))
->nonInteractively(fn () => $this->getWorkerDefult('backoff'))
->nonInteractively(fn () => $this->getWorkerDefault('backoff'))
->shouldPromptOnce(),
'backoff',
);
Expand All @@ -186,11 +186,11 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => number(
label: 'Sleep',
default: $value ?? $this->getWorkerDefult('sleep'),
default: $value ?? $this->getWorkerDefault('sleep'),
required: true,
hint: 'Number of seconds to sleep when no jobs are available',
))
->nonInteractively(fn () => $this->getWorkerDefult('sleep'))
->nonInteractively(fn () => $this->getWorkerDefault('sleep'))
->shouldPromptOnce(),
'sleep',
);
Expand All @@ -200,11 +200,11 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => number(
label: 'Rest',
default: $value ?? $this->getWorkerDefult('rest'),
default: $value ?? $this->getWorkerDefault('rest'),
required: true,
hint: 'Number of seconds to rest between jobs',
))
->nonInteractively(fn () => $this->getWorkerDefult('rest'))
->nonInteractively(fn () => $this->getWorkerDefault('rest'))
->shouldPromptOnce(),
'rest',
);
Expand All @@ -214,11 +214,11 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => number(
label: 'Timeout',
default: $value ?? $this->getWorkerDefult('timeout'),
default: $value ?? $this->getWorkerDefault('timeout'),
required: true,
hint: 'Number of seconds a job can run before timing out',
))
->nonInteractively(fn () => $this->getWorkerDefult('timeout'))
->nonInteractively(fn () => $this->getWorkerDefault('timeout'))
->shouldPromptOnce(),
'timeout',
);
Expand All @@ -228,10 +228,10 @@ protected function addWorkerParams(): void
fn ($resolver) => $resolver
->fromInput(fn (?string $value) => confirm(
label: 'Run in maintenance mode?',
default: (bool) ($value ?? $this->getWorkerDefult('force')),
default: (bool) ($value ?? $this->getWorkerDefault('force')),
hint: 'Force the worker to run even in maintenance mode',
))
->nonInteractively(fn () => $this->getWorkerDefult('force'))
->nonInteractively(fn () => $this->getWorkerDefault('force'))
->shouldPromptOnce(),
'force',
);
Expand All @@ -250,14 +250,14 @@ protected function wantsToEditWorkerDefaults(): bool
}

dataList([
'Connection' => $this->getWorkerDefult('connection'),
'Queue' => $this->getWorkerDefult('queue'),
'Tries' => $this->getWorkerDefult('tries'),
'Backoff' => $this->getWorkerDefult('backoff'),
'Sleep' => $this->getWorkerDefult('sleep'),
'Rest' => $this->getWorkerDefult('rest'),
'Timeout' => $this->getWorkerDefult('timeout'),
'Force to run in maintenance mode' => $this->getWorkerDefult('force') ? 'Yes' : 'No',
'Connection' => $this->getWorkerDefault('connection'),
'Queue' => $this->getWorkerDefault('queue'),
'Tries' => $this->getWorkerDefault('tries'),
'Backoff' => $this->getWorkerDefault('backoff'),
'Sleep' => $this->getWorkerDefault('sleep'),
'Rest' => $this->getWorkerDefault('rest'),
'Timeout' => $this->getWorkerDefault('timeout'),
'Force to run in maintenance mode' => $this->getWorkerDefault('force') ? 'Yes' : 'No',
]);

return confirm(
Expand All @@ -266,7 +266,7 @@ protected function wantsToEditWorkerDefaults(): bool
);
}

protected function getWorkerDefult(string $key): ?string
protected function getWorkerDefault(string $key): ?string
{
$arg = $this->option($key);

Expand Down
9 changes: 3 additions & 6 deletions app/Commands/BackgroundProcessList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class BackgroundProcessList extends BaseCommand
{
Expand All @@ -29,14 +28,12 @@ public function handle()

$items = $processes->collect();

$this->outputJsonIfWanted($items);

if ($items->isEmpty()) {
warning('No background processes found.');

return self::FAILURE;
$this->failAndExit('No background processes found.');
}

$this->outputJsonIfWanted($items);

dataTable(
headers: ['ID', 'Command', 'Type', 'Processes'],
rows: $items->map(fn ($process) => [
Expand Down
3 changes: 2 additions & 1 deletion app/Commands/BucketDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class BucketDelete extends BaseCommand
{
protected $signature = 'bucket:delete
{bucket? : The bucket ID or name}
{--force : Skip confirmation}';
{--force : Skip confirmation}
{--json : Output as JSON}';

protected $description = 'Delete an object storage bucket';

Expand Down
9 changes: 3 additions & 6 deletions app/Commands/BucketKeyList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class BucketKeyList extends BaseCommand
{
Expand All @@ -32,14 +31,12 @@ public function handle()

$items = collect($keys);

$this->outputJsonIfWanted($items->toArray());

if ($items->isEmpty()) {
warning('No keys found.');

return self::FAILURE;
$this->failAndExit('No keys found.');
}

$this->outputJsonIfWanted($items->toArray());

dataTable(
headers: ['ID', 'Name', 'Permission', 'Created At'],
rows: $items->map(fn (BucketKey $k) => [
Expand Down
9 changes: 3 additions & 6 deletions app/Commands/BucketList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class BucketList extends BaseCommand
{
Expand Down Expand Up @@ -36,14 +35,12 @@ public function handle()
'Fetching buckets...',
);

$this->outputJsonIfWanted($buckets->toArray());

if ($buckets->isEmpty()) {
warning('No buckets found.');

return self::FAILURE;
$this->failAndExit('No buckets found.');
}

$this->outputJsonIfWanted($buckets->toArray());

dataTable(
headers: ['ID', 'Name', 'Type', 'Status', 'Visibility', 'Region'],
rows: $buckets->map(fn (ObjectStorageBucket $b) => [
Expand Down
3 changes: 2 additions & 1 deletion app/Commands/CacheDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class CacheDelete extends BaseCommand
{
protected $signature = 'cache:delete
{cache? : The cache ID or name}
{--force : Skip confirmation}';
{--force : Skip confirmation}
{--json : Output as JSON}';

protected $description = 'Delete a cache';

Expand Down
9 changes: 3 additions & 6 deletions app/Commands/CacheList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class CacheList extends BaseCommand
{
Expand All @@ -30,14 +29,12 @@ public function handle()

$items = collect($caches);

$this->outputJsonIfWanted($items);

if ($items->isEmpty()) {
warning('No caches found.');

return self::FAILURE;
$this->failAndExit('No caches found.');
}

$this->outputJsonIfWanted($items);

dataTable(
headers: ['ID', 'Name', 'Type', 'Status', 'Region', 'Size'],
rows: $items->map(fn (Cache $cache) => [
Expand Down
9 changes: 3 additions & 6 deletions app/Commands/CacheTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\table;
use function Laravel\Prompts\warning;

class CacheTypes extends BaseCommand
{
Expand All @@ -28,14 +27,12 @@ public function handle()

$items = collect($types);

$this->outputJsonIfWanted($items);

if ($items->isEmpty()) {
warning('No cache types found.');

return self::FAILURE;
$this->failAndExit('No cache types found.');
}

$this->outputJsonIfWanted($items);

$rows = collect($types)->map(fn (CacheType $type, $index) => [
$type->label,
$type->supportsAutoUpgrade ? 'Yes' : 'No',
Expand Down
9 changes: 3 additions & 6 deletions app/Commands/DatabaseClusterList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class DatabaseClusterList extends BaseCommand
{
Expand All @@ -27,14 +26,12 @@ public function handle()

$items = $databases->collect();

$this->outputJsonIfWanted($items);

if ($items->isEmpty()) {
warning('No databases found.');

return self::FAILURE;
$this->failAndExit('No databases found.');
}

$this->outputJsonIfWanted($items);

dataTable(
headers: ['ID', 'Name', 'Type', 'Status', 'Region', 'Schemas'],
rows: $items->map(fn ($db) => [
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/DatabaseDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Commands;

use Throwable;
use Saloon\Exceptions\Request\RequestException;

use function Laravel\Prompts\confirm;
use function Laravel\Prompts\error;
Expand Down Expand Up @@ -48,7 +48,7 @@ public function handle()
success('Database deleted.');

return self::SUCCESS;
} catch (Throwable $e) {
} catch (RequestException $e) {
error('Failed to delete database: '.$e->getMessage());

return self::FAILURE;
Expand Down
9 changes: 3 additions & 6 deletions app/Commands/DatabaseList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use function Laravel\Prompts\intro;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\warning;

class DatabaseList extends BaseCommand
{
Expand All @@ -29,14 +28,12 @@ public function handle()
'Fetching databases...',
);

$this->outputJsonIfWanted($databases->toArray());

if ($databases->isEmpty()) {
warning('No databases found.');

return self::FAILURE;
$this->failAndExit('No databases found.');
}

$this->outputJsonIfWanted($databases->toArray());

dataTable(
headers: ['ID', 'Name', 'Created At'],
rows: $databases->map(fn ($database) => [
Expand Down
Loading
Loading