run method
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.get('/grants') as List).cast<Map>();
if (grants.isEmpty) {
stdout.writeln('no credentials have been issued');
return;
}
stdout.writeln('ID PRINCIPAL ROLES');
for (final g in grants) {
final id = '${g['id']}'.padRight(25);
final principal = '${g['principal']}'.padRight(13);
final roles = (g['roles'] as List).join(',');
final note = '${g['note'] ?? ''}';
stdout.writeln(
'$id $principal$roles${note.isEmpty ? '' : ' # $note'}',
);
}
} finally {
client.close();
}
}