runWithOutput method

  1. @override
Future<void> runWithOutput(
  1. Configuration<DbScheduleSetOption> commandConfig,
  2. CommandOutput output
)
override

Runs this command with prepared configuration and output.

Subclasses should override this method.

Implementation

@override
Future<void> runWithOutput(
  final Configuration<DbScheduleSetOption> commandConfig,
  final CommandOutput output,
) 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 renderCommand(
    output,
    operation: () => DbBackupOperations.setSchedule(
      runner.serviceProvider.cloudApiClient,
      projectId: commandConfig.value(DbScheduleSetOption.projectId),
      frequency: frequency,
      day: day,
      hour: commandConfig.optionalValue(DbScheduleSetOption.hour),
      retention: commandConfig.optionalValue(DbScheduleSetOption.retention),
    ),
    textOutputUi: const BackupScheduleSetTextUi(),
  );
}