run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<int> run() async {
final rest = argResults!.rest;
if (rest.length != 1) {
return _error(
ExitReporter.usageError,
'MISSING_PLAN_ID',
'Expected exactly one plan ID.',
);
}
final planId = rest.single;
final plan = planStore.loadPlan(planId);
if (plan == null) {
return _error(
ExitReporter.planNotFoundOrStateForbids,
'PLAN_NOT_FOUND',
'Change Plan "$planId" was not found.',
);
}
final location = planStore.loadPlanLocation(planId);
if (location == null) {
return _error(
ExitReporter.planNotFoundOrStateForbids,
'PLAN_LOCATION_NOT_FOUND',
'Change Plan "$planId" has no staging location.',
);
}
try {
return await withSessionLock(
location.canonicalDestination,
() => _apply(plan, location),
baseDir: sessionLockBaseDir,
);
} on SessionLockHeldException catch (error) {
return _error(error.exitCode, 'SESSION_LOCK_HELD', error.message);
}
}