listProjects static method

Future<void> listProjects(
  1. Client cloudApiClient, {
  2. required CommandLogger logger,
  3. bool inUtc = false,
  4. bool includeArchived = false,
})

Implementation

static Future<void> listProjects(
  final Client cloudApiClient, {
  required final CommandLogger logger,
  final bool inUtc = false,
  final bool includeArchived = false,
}) async {
  final projects = await cloudApiClient.adminProjects.listProjects(
    includeArchived: includeArchived,
  );

  final timezoneName = inUtc ? 'UTC' : 'local';

  final table = TablePrinter(
    headers: [
      'Project Id',
      'Created at ($timezoneName)',
      'Archived at ($timezoneName)',
      'Owner',
      'Users',
    ],
    rows: projects.map((final p) => [
          p.cloudProjectId,
          p.createdAt.toTzString(inUtc, 19),
          p.archivedAt?.toTzString(inUtc, 19),
          p.owner?.user?.email ?? '',
          _formatProjectUsers(p),
        ]),
  );
  table.writeLines(logger.line);
}