Skip to content

Commit

Permalink
Clarify table header and default columns types
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 18, 2024
1 parent 487dd34 commit 5fcdb86
Show file tree
Hide file tree
Showing 38 changed files with 73 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Command/Activity/ActivityListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#[AsCommand(name: 'activity:list', description: 'Get a list of activities for an environment or project', aliases: ['activities', 'act'])]
class ActivityListCommand extends ActivityCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'ID',
'created' => 'Created',
Expand All @@ -35,6 +36,7 @@ class ActivityListCommand extends ActivityCommandBase
'time_deploy' => 'Deploy time (s)',
];

/** @var string[] */
private array $defaultColumns = ['id', 'created', 'description', 'progress', 'state', 'result'];

public function __construct(private readonly ActivityLoader $activityLoader, private readonly Api $api, private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
Expand Down
3 changes: 3 additions & 0 deletions src/Command/App/AppListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
#[AsCommand(name: 'app:list', description: 'List apps in the project', aliases: ['apps'])]
class AppListCommand extends CommandBase
{
/** @var array<string|int, string> */
private array $tableHeader = ['Name', 'Type', 'disk' => 'Disk', 'Size', 'path' => 'Path'];
/** @var string[] */
private array $defaultColumns = ['name', 'type'];

public function __construct(private readonly Api $api, private readonly ApplicationFinder $applicationFinder, private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
parent::__construct();
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Backup/BackupListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
class BackupListCommand extends CommandBase
{

/** @var array<string, string> */
private array $tableHeader = [
'created_at' => 'Created',
'id' => 'Backup ID',
Expand All @@ -29,6 +30,7 @@ class BackupListCommand extends CommandBase
'status' => 'Status',
'updated_at' => 'Updated',
];
/** @var string[] */
private array $defaultColumns = ['created_at', 'id', 'restorable'];
public function __construct(private readonly Api $api, private readonly Io $io, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
1 change: 1 addition & 0 deletions src/Command/Certificate/CertificateListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#[AsCommand(name: 'certificate:list', description: 'List project certificates', aliases: ['certificates', 'certs'])]
class CertificateListCommand extends CommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'ID',
'domains' => 'Domain(s)',
Expand Down
3 changes: 2 additions & 1 deletion src/Command/Commit/CommitListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
#[AsCommand(name: 'commit:list', description: 'List commits', aliases: ['commits'])]
class CommitListCommand extends CommandBase
{

/** @var array<string|int, string> */
private array $tableHeader = ['Date', 'SHA', 'Author', 'Summary'];

public function __construct(private readonly Api $api, private readonly GitDataApi $gitDataApi, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
parent::__construct();
Expand Down
1 change: 1 addition & 0 deletions src/Command/Db/DbSizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
class DbSizeCommand extends CommandBase
{

/** @var array<string, string> */
private array $tableHeader = ['max' => 'Allocated disk', 'used' => 'Estimated usage', 'percent_used' => '% used'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly Io $io, private readonly QuestionHelper $questionHelper, private readonly Relationships $relationships, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Domain/DomainListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#[AsCommand(name: 'domain:list', description: 'Get a list of all domains', aliases: ['domains'])]
class DomainListCommand extends DomainCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'name' => 'Name',
'ssl' => 'SSL enabled',
Expand All @@ -27,6 +28,7 @@ class DomainListCommand extends DomainCommandBase
'replacement_for' => 'Attached domain',
'type' => 'Type',
];
/** @var string[] */
private array $defaultColumns = ['name', 'ssl', 'created_at'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Environment/EnvironmentListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#[AsCommand(name: 'environment:list', description: 'Get a list of environments', aliases: ['environments', 'env'])]
class EnvironmentListCommand extends CommandBase
{
/** @var array<string|int, string> */
private array $tableHeader = ['ID', 'machine_name' => 'Machine name', 'Title', 'Status', 'Type', 'Created', 'Updated'];
/** @var string[] */
private array $defaultColumns = ['id', 'title', 'status', 'type'];

private Environment|false $currentEnvironment = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#[AsCommand(name: 'integration:activity:list', description: 'Get a list of activities for an integration', aliases: ['integration:activities'])]
class IntegrationActivityListCommand extends IntegrationCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'ID',
'created' => 'Created',
Expand All @@ -37,6 +38,7 @@ class IntegrationActivityListCommand extends IntegrationCommandBase
'time_build' => 'Build time (s)',
'time_deploy' => 'Deploy time (s)',
];
/** @var string[] */
private array $defaultColumns = ['id', 'created', 'description', 'type', 'state', 'result'];
public function __construct(private readonly ActivityLoader $activityLoader, private readonly Api $api, private readonly Config $config, private readonly Io $io, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
1 change: 1 addition & 0 deletions src/Command/Integration/IntegrationListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#[AsCommand(name: 'integration:list', description: 'View a list of project integration(s)', aliases: ['integrations'])]
class IntegrationListCommand extends IntegrationCommandBase
{
/** @var array<string|int, string> */
private array $tableHeader = ['ID', 'Type', 'Summary'];
public function __construct(private readonly Config $config, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Metrics/AllMetricsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#[AsCommand(name: 'metrics:all', description: 'Show CPU, disk and memory metrics for an environment', aliases: ['metrics', 'met'])]
class AllMetricsCommand extends MetricsCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'timestamp' => 'Timestamp',
'service' => 'Service',
Expand Down Expand Up @@ -45,6 +46,7 @@ class AllMetricsCommand extends MetricsCommandBase
'tmp_inodes_percent' => '/tmp inodes %',
];

/** @var string[] */
private array $defaultColumns = ['timestamp', 'service', 'cpu_percent', 'mem_percent', 'disk_percent', 'tmp_disk_percent'];
public function __construct(private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Metrics/CpuCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#[AsCommand(name: 'metrics:cpu', description: 'Show CPU usage of an environment', aliases: ['cpu'])]
class CpuCommand extends MetricsCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'timestamp' => 'Timestamp',
'service' => 'Service',
Expand All @@ -23,6 +24,7 @@ class CpuCommand extends MetricsCommandBase
'percent' => 'Used %',
];

/** @var string[] */
private array $defaultColumns = ['timestamp', 'service', 'used', 'limit', 'percent'];
public function __construct(private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Metrics/DiskUsageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#[AsCommand(name: 'metrics:disk-usage', description: 'Show disk usage of an environment', aliases: ['disk'])]
class DiskUsageCommand extends MetricsCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'timestamp' => 'Timestamp',
'service' => 'Service',
Expand All @@ -32,6 +33,7 @@ class DiskUsageCommand extends MetricsCommandBase
'tmp_ilimit' => '/tmp inodes limit',
'tmp_ipercent' => '/tmp inodes %',
];
/** @var string[] */
private array $defaultColumns = ['timestamp', 'service', 'used', 'limit', 'percent', 'ipercent', 'tmp_percent'];
private array $tmpReportColumns = ['timestamp', 'service', 'tmp_used', 'tmp_limit', 'tmp_percent', 'tmp_ipercent'];
public function __construct(private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Metrics/MemCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#[AsCommand(name: 'metrics:memory', description: 'Show memory usage of an environment', aliases: ['mem', 'memory'])]
class MemCommand extends MetricsCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'timestamp' => 'Timestamp',
'service' => 'Service',
Expand All @@ -24,6 +25,7 @@ class MemCommand extends MetricsCommandBase
'percent' => 'Used %',
];

/** @var string[] */
private array $defaultColumns = ['timestamp', 'service', 'used', 'limit', 'percent'];
public function __construct(private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
1 change: 1 addition & 0 deletions src/Command/Mount/MountListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#[AsCommand(name: 'mount:list', description: 'Get a list of mounts', aliases: ['mounts'])]
class MountListCommand extends CommandBase
{
/** @var array<string, string> */
private array $tableHeader = ['path' => 'Mount path', 'definition' => 'Definition'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly Io $io, private readonly Mount $mount, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
1 change: 1 addition & 0 deletions src/Command/Mount/MountSizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#[AsCommand(name: 'mount:size', description: 'Check the disk usage of mounts')]
class MountSizeCommand extends CommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'mounts' => 'Mount(s)',
'sizes' => 'Size(s)',
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Organization/OrganizationListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#[AsCommand(name: 'organization:list', description: 'List organizations', aliases: ['orgs', 'organizations'])]
class OrganizationListCommand extends OrganizationCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'ID',
'name' => 'Name',
Expand All @@ -23,6 +24,7 @@ class OrganizationListCommand extends OrganizationCommandBase
'owner_email' => 'Owner email',
'owner_username' => 'Owner username',
];
/** @var string[] */
private array $defaultColumns = ['name', 'label', 'owner_email'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#[AsCommand(name: 'organization:subscription:list', description: 'List subscriptions within an organization', aliases: ['org:subs'])]
class OrganizationSubscriptionListCommand extends OrganizationCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'Subscription ID',
'project_id' => 'Project ID',
Expand All @@ -24,6 +25,7 @@ class OrganizationSubscriptionListCommand extends OrganizationCommandBase
'updated_at' => 'Updated at',
];

/** @var string[] */
private array $defaultColumns = ['id', 'project_id', 'project_title', 'project_region'];

public function __construct(private readonly Api $api, private readonly Config $config, private readonly Selector $selector, private readonly Table $table)
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Organization/User/OrganizationUserListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#[AsCommand(name: 'organization:user:list', description: 'List organization users', aliases: ['org:users'])]
class OrganizationUserListCommand extends OrganizationCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'ID',
'first_name' => 'First name',
Expand All @@ -31,6 +32,7 @@ class OrganizationUserListCommand extends OrganizationCommandBase
'created_at' => 'Created at',
'updated_at' => 'Updated at',
];
/** @var string[] */
private array $defaultColumns = ['id', 'email', 'owner', 'permissions'];

public function __construct(private readonly Api $api, private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#[AsCommand(name: 'organization:user:projects', description: 'List the projects a user can access', aliases: ['oups'])]
class OrganizationUserProjectsCommand extends OrganizationCommandBase
{
/** @var array<string, string> */
protected array $tableHeader = [
'organization_id' => 'Organization ID',
'organization_name' => 'Organization',
Expand All @@ -35,6 +36,7 @@ class OrganizationUserProjectsCommand extends OrganizationCommandBase
'region' => 'Region',
];

/** @var string[] */
protected array $defaultColumns = ['project_id', 'project_title', 'roles', 'updated_at'];

public function __construct(private readonly Api $api, private readonly Config $config, private readonly Io $io, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Project/ProjectListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#[AsCommand(name: 'project:list', description: 'Get a list of all active projects', aliases: ['projects', 'pro'])]
class ProjectListCommand extends CommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'ID',
'title' => 'Title',
Expand All @@ -31,6 +32,7 @@ class ProjectListCommand extends CommandBase
'status' => 'Status',
'created_at' => 'Created',
];
/** @var string[] */
private array $defaultColumns = ['id', 'title', 'region'];

public function __construct(
Expand Down
1 change: 1 addition & 0 deletions src/Command/Resources/Build/BuildResourcesGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#[AsCommand(name: 'resources:build:get', description: 'View the build resources of a project', aliases: ['build-resources:get', 'build-resources'])]
class BuildResourcesGetCommand extends CommandBase
{
/** @var array<string, string> */
protected array $tableHeader = [
'cpu' => 'CPU',
'memory' => 'Memory (MB)',
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Resources/ResourcesGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#[AsCommand(name: 'resources:get', description: 'View the resources of apps and services on an environment', aliases: ['resources', 'res'])]
class ResourcesGetCommand extends ResourcesCommandBase
{
/** @var array<string, string> */
protected array $tableHeader = [
'service' => 'App or service',
'type' => 'Type',
Expand All @@ -30,6 +31,7 @@ class ResourcesGetCommand extends ResourcesCommandBase
'base_memory' => 'Base memory',
'memory_ratio' => 'Memory ratio',
];
/** @var string[] */
protected array $defaultColumns = ['service', 'profile_size', 'cpu', 'memory', 'disk', 'instance_count'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly ResourcesUtil $resourcesUtil, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
1 change: 1 addition & 0 deletions src/Command/Resources/ResourcesSizeListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#[AsCommand(name: 'resources:size:list', description: 'List container profile sizes', aliases: ['resources:sizes'])]
class ResourcesSizeListCommand extends ResourcesCommandBase
{
/** @var array<string, string> */
protected array $tableHeader = ['size' => 'Size name', 'cpu' => 'CPU', 'memory' => 'Memory (MB)'];
public function __construct(private readonly Api $api, private readonly QuestionHelper $questionHelper, private readonly ResourcesUtil $resourcesUtil, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Route/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
#[AsCommand(name: 'route:list', description: 'List all routes for an environment', aliases: ['routes'])]
class RouteListCommand extends CommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'route' => 'Route',
'type' => 'Type',
'to' => 'To',
'url' => 'URL',
];
/** @var string[] */
private array $defaultColumns = ['route', 'type', 'to'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly Io $io, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/RuntimeOperation/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class ListCommand extends CommandBase
{
const COMMAND_MAX_LENGTH = 24;

/** @var array<string, string> */
private array $tableHeader = ['service' => 'Service', 'name' => 'Operation name', 'start' => 'Start command', 'stop' => 'Stop command', 'role' => 'Role'];
/** @var string[] */
private array $defaultColumns = ['service', 'name', 'start'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly Selector $selector, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Self/SelfStatsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class SelfStatsCommand extends CommandBase
{
protected bool $hiddenInList = true;

/** @var array<string|int, string> */
private array $tableHeader = ['Release', 'Date', 'Asset', 'Downloads'];

public function __construct(private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly Table $table)
{
parent::__construct();
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Service/ServiceListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#[AsCommand(name: 'service:list', description: 'List services in the project', aliases: ['services'])]
class ServiceListCommand extends CommandBase
{
/** @var array<string|int, string> */
private array $tableHeader = ['Name', 'Type', 'disk' => 'Disk (MiB)', 'Size'];

public function __construct(private readonly Api $api, private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
{
parent::__construct();
Expand Down
2 changes: 2 additions & 0 deletions src/Command/SourceOperation/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class ListCommand extends CommandBase
{
const COMMAND_MAX_LENGTH = 24;

/** @var array<string|int, string> */
private array $tableHeader = ['Operation', 'App', 'Command'];

public function __construct(private readonly Api $api, private readonly Config $config, private readonly Selector $selector, private readonly Table $table)
{
parent::__construct();
Expand Down
2 changes: 2 additions & 0 deletions src/Command/SshKey/SshKeyListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#[AsCommand(name: 'ssh-key:list', description: 'Get a list of SSH keys in your account', aliases: ['ssh-keys'])]
class SshKeyListCommand extends SshKeyCommandBase
{
/** @var array<string, string> */
private array $tableHeader = [
'id' => 'ID',
'title' => 'Title',
'fingerprint' => 'Fingerprint',
'path' => 'Local path'
];
/** @var string[] */
private array $defaultColumns = ['id', 'title', 'path'];
public function __construct(private readonly Api $api, private readonly Config $config, private readonly SshKey $sshKey, private readonly Table $table)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Team/Project/TeamProjectListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ class TeamProjectListCommand extends TeamCommandBase
{
const MAX_COUNT = 200;

/** @var array<string, string> */
private array $tableHeader = [
'id' => 'Project ID',
'title' => 'Project title',
'granted_at' => 'Date added',
'updated_at' => 'Updated at',
];
/** @var string[] */
private array $defaultColumns = ['id', 'title', 'granted_at'];

public function __construct(private readonly Api $api, private readonly Config $config, private readonly PropertyFormatter $propertyFormatter, private readonly Selector $selector, private readonly Table $table)
Expand Down
Loading

0 comments on commit 5fcdb86

Please sign in to comment.