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 rest = argResults!.rest;
if (rest.isEmpty) throw CliError('usage: blueprint plan <node>');
final client = _apiClientFrom(argResults!);
try {
final drift = await client.drift(rest.first);
if (drift == null) {
throw CliError('nothing is declared for ${rest.first}');
}
if (drift.converged) {
stdout.writeln('${rest.first} is converged (${drift.blueprint})');
return;
}
stdout.writeln('${rest.first} has drifted from ${drift.blueprint}:');
for (final c in drift.changes) {
if (c.kind == ChangeKind.noop) continue;
stdout.writeln(' ${c.kind.name.padRight(8)} ${c.id} — ${c.reason}');
}
// A distinct code, so this is usable in CI and on a timer without anyone
// having to parse the output.
exitCode = 2;
} finally {
client.close();
}
}