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 args = argResults!;

  final client = _apiClientFrom(args);
  try {
    final ops = await client.operations(
      nodeId: args['node'] as String?,
      running: args['running'] as bool,
    );
    if (ops.isEmpty) {
      stdout.writeln('no operations');
      return;
    }
    stdout.writeln(
      'ID                                    NODE        STATUS     WHAT',
    );
    for (final op in ops) {
      stdout.writeln(
        '${op.id.padRight(37)} ${op.nodeId.padRight(11)} '
        '${op.status.name.padRight(10)} ${op.kind} ${op.summary}',
      );
    }
  } finally {
    client.close();
  }
}