runWithOutput method

  1. @override
Future<void> runWithOutput(
  1. Configuration<DbWipeOption> 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<DbWipeOption> commandConfig,
  final CommandOutput output,
) async {
  final projectId = commandConfig.value(DbWipeOption.projectId);

  if (!globalConfiguration.skipConfirmation) {
    final confirmed = await output.renderInteractive(
      ui: ConfirmationWidget('''
WARNING: Deletes all tables and data in the database for project "$projectId".
This is a NON-REVERSIBLE action.
The server will error until a redeploy is performed.

Do you want to proceed?''', defaultValue: false),
    );
    if (!confirmed) {
      await renderCommand(
        output,
        operation: () async => const <String, Object?>{},
        textOutputUi: const DbWipeCancelledTextUi(),
      );
      return;
    }
  }

  await renderCommand(
    output,
    operation: () async => Stream.fromFuture(
      DbOperations.wipeDatabase(
        runner.serviceProvider.cloudApiClient,
        projectId: projectId,
      ),
    ),
    textOutputUi: DbWipeTextUi(
      baseCommand: baseCommand,
      projectId: projectId,
    ),
  );
}