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 args = argResults!;
final query = [
if (args['node'] != null)
'node=${Uri.encodeQueryComponent(args['node'] as String)}',
if (args['running'] as bool) 'running=true',
].join('&');
final client = _apiClientFrom(args);
try {
final ops =
(await client.get('/operations${query.isEmpty ? '' : '?$query'}')
as List)
.cast<Map>();
if (ops.isEmpty) {
stdout.writeln('no operations');
return;
}
stdout.writeln(
'ID NODE STATUS WHAT',
);
for (final op in ops) {
final id = '${op['id']}'.padRight(37);
final node = '${op['nodeId']}'.padRight(11);
final status = '${op['status']}'.padRight(10);
stdout.writeln('$id $node $status ${op['kind']} ${op['summary']}');
}
} finally {
client.close();
}
}