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 rest = args.rest;
  if (rest.isEmpty) {
    throw CliError(
      'usage: blueprint assign <id> [<node>] [--label env=prod | --all]',
    );
  }
  final blueprint = rest.first;

  final client = _apiClientFrom(args);
  try {
    final nodes = await _selectNodes(
      client,
      args,
      positional: rest.skip(1).toList(),
    );
    await _fanOut(nodes, (node) async {
      await client.assignBlueprint(node, blueprint);
      return 'assigned $blueprint';
    });
    // Said plainly: an operator who expects this to have *done* something will
    // otherwise wonder why the machine is unchanged.
    stdout.writeln('nothing has run — blueprint apply <node> to make it so');
  } finally {
    client.close();
  }
}