From 68de3600bd6418eae3ea23d460c527e82d45608a Mon Sep 17 00:00:00 2001 From: Abrar Ahmad Date: Wed, 14 Dec 2022 19:08:00 +0500 Subject: [PATCH] Improve commands CLI output (#1030) * use component info/error methods * Update src/Commands/ClearPendingTenants.php Co-authored-by: lukinovec Co-authored-by: lukinovec --- src/Commands/ClearPendingTenants.php | 7 +++---- src/Commands/CreatePendingTenants.php | 6 +++--- src/Commands/Link.php | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Commands/ClearPendingTenants.php b/src/Commands/ClearPendingTenants.php index 82b01cd0..0e27a209 100644 --- a/src/Commands/ClearPendingTenants.php +++ b/src/Commands/ClearPendingTenants.php @@ -17,7 +17,7 @@ class ClearPendingTenants extends Command public function handle(): int { - $this->info('Removing pending tenants.'); + $this->components->info('Removing pending tenants.'); $expirationDate = now(); // We compare the original expiration date to the new one to check if the new one is different later @@ -27,8 +27,7 @@ class ClearPendingTenants extends Command $olderThanHours = (int) $this->option('older-than-hours'); if ($olderThanDays && $olderThanHours) { - $this->line(" Cannot use '--older-than-days' and '--older-than-hours' together \n"); // todo@cli refactor all of these styled command outputs to use $this->components - $this->line('Please, choose only one of these options.'); + $this->components->error("Cannot use '--older-than-days' and '--older-than-hours' together. Please, choose only one of these options."); return 1; // Exit code for failure } @@ -51,7 +50,7 @@ class ClearPendingTenants extends Command ->delete() ->count(); - $this->info($deletedTenantCount . ' pending ' . str('tenant')->plural($deletedTenantCount) . ' deleted.'); + $this->components->info($deletedTenantCount . ' pending ' . str('tenant')->plural($deletedTenantCount) . ' deleted.'); return 0; } diff --git a/src/Commands/CreatePendingTenants.php b/src/Commands/CreatePendingTenants.php index 5c255664..c37b8bd7 100644 --- a/src/Commands/CreatePendingTenants.php +++ b/src/Commands/CreatePendingTenants.php @@ -14,7 +14,7 @@ class CreatePendingTenants extends Command public function handle(): int { - $this->info('Creating pending tenants.'); + $this->components->info('Creating pending tenants.'); $maxPendingTenantCount = (int) ($this->option('count') ?? config('tenancy.pending.count')); $pendingTenantCount = $this->getPendingTenantCount(); @@ -30,8 +30,8 @@ class CreatePendingTenants extends Command $createdCount++; } - $this->info($createdCount . ' pending ' . str('tenant')->plural($createdCount) . ' created.'); - $this->info($maxPendingTenantCount . ' pending ' . str('tenant')->plural($maxPendingTenantCount) . ' ready to be used.'); + $this->components->info($createdCount . ' pending ' . str('tenant')->plural($createdCount) . ' created.'); + $this->components->info($maxPendingTenantCount . ' pending ' . str('tenant')->plural($maxPendingTenantCount) . ' ready to be used.'); return 0; } diff --git a/src/Commands/Link.php b/src/Commands/Link.php index a6dd6c5f..d49cc7f2 100644 --- a/src/Commands/Link.php +++ b/src/Commands/Link.php @@ -34,7 +34,7 @@ class Link extends Command $this->createLinks($tenants); } } catch (Exception $exception) { - $this->error($exception->getMessage()); + $this->components->error($exception->getMessage()); return 1; }