runWithConfig method

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

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

Implementation

@override
Future<void> runWithConfig(
  final Configuration<DbResetPasswordOption> commandConfig,
) async {
  final projectId = commandConfig.value(DbResetPasswordOption.projectId);
  final username = commandConfig.value(DbResetPasswordOption.username);

  final apiCloudClient = runner.serviceProvider.cloudApiClient;

  try {
    final password = await apiCloudClient.database.resetDatabasePassword(
      cloudCapsuleId: projectId,
      username: username,
    );

    logger.success(
      '''
DB password is reset. The new password is only shown this once:
$password''',
    );
  } on Exception catch (e, stackTrace) {
    throw FailureException.nested(e, stackTrace, 'Failed to reset password');
  }
}