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 labels = args['label'] as List<String>;
final online = (args['offline'] as bool)
? false
: (args.wasParsed('online') ? args['online'] as bool : null);
final narrowed = labels.isNotEmpty || online != null;
final client = _apiClientFrom(args);
try {
final nodes = await client.nodes(labels: labels, online: online);
if (nodes.isEmpty) {
stdout.writeln(narrowed ? 'no node matches' : 'no nodes registered');
return;
}
stdout.writeln('NODE ONLINE PLATFORM LABELS');
for (final n in nodes) {
final rendered = n.labels.entries
.map((l) => '${l.key}=${l.value}')
.join(' ');
stdout.writeln(
'${n.id.value.padRight(20)} ${n.online ? 'yes ' : 'no '} '
'${n.platform.osName.padRight(10)} $rendered',
);
}
} finally {
client.close();
}
}