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 rest = argResults!.rest;
  if (rest.isEmpty) throw CliError('usage: node status <id>');
  final client = _apiClientFrom(argResults!);
  try {
    final status = await client.nodeStatus(rest.first);
    if (status == null) {
      stdout.writeln('no status yet — the node has not heartbeated');
      return;
    }
    stdout.writeln(
      const JsonEncoder.withIndent('  ').convert(status.toJson()),
    );
  } finally {
    client.close();
  }
}