run method

  1. @override
Future<void> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<void> run() async {
  final client = _apiClientFrom(argResults!);
  try {
    final grants = await client.grants();
    if (grants.isEmpty) {
      stdout.writeln('no credentials have been issued');
      return;
    }
    stdout.writeln('ID                        PRINCIPAL     ROLES');
    for (final g in grants) {
      stdout.writeln(
        '${g.id.padRight(25)} ${g.principal.value.padRight(13)}'
        '${g.roles.join(',')}${g.note.isEmpty ? '' : '   # ${g.note}'}',
      );
    }
  } finally {
    client.close();
  }
}