runWithConfig method

  1. @override
Future<void> runWithConfig(
  1. Configuration<DbScheduleSetOption> commandConfig
)
override

Runs this command with prepared configuration (options). Subclasses should override this method.

Implementation

@override
Future<void> runWithConfig(
  final Configuration<DbScheduleSetOption> commandConfig,
) async {
  final frequency = commandConfig.value(DbScheduleSetOption.frequency);
  final day = commandConfig.optionalValue(DbScheduleSetOption.day);

  if (frequency == BackupFrequency.weekly &&
      day != null &&
      (day < 1 || day > 7)) {
    throw CloudCliUsageException(
      'The --day value must be between 1 and 7 for a weekly schedule.',
    );
  }

  await DbBackupCommands.setSchedule(
    runner.serviceProvider.cloudApiClient,
    logger: logger,
    projectId: commandConfig.value(DbScheduleSetOption.projectId),
    frequency: frequency,
    day: day,
    hour: commandConfig.optionalValue(DbScheduleSetOption.hour),
    retention: commandConfig.optionalValue(DbScheduleSetOption.retention),
  );
}