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 update <id> [--target agent]');
  }
  final client = _apiClientFrom(argResults!);
  try {
    final target = argResults!['target'] as String;
    await client.post('/nodes/${rest.first}/update', {'target': target});
    stdout.writeln('update ($target) requested for ${rest.first}');
  } finally {
    client.close();
  }
}