runWithConfig method

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

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

Implementation

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

  final shouldDelete = await logger.confirm(
    'Are you sure you want to delete the custom domain "$domainName"?',
    defaultValue: false,
  );

  if (!shouldDelete) {
    throw UserAbortException();
  }

  final apiCloudClient = runner.serviceProvider.cloudApiClient;

  try {
    await apiCloudClient.customDomainName.remove(
      cloudCapsuleId: projectId,
      domainName: domainName,
    );
  } on Exception catch (e, stackTrace) {
    throw FailureException.nested(
        e, stackTrace, 'Failed to remove custom domain');
  }

  logger.success('Successfully removed custom domain: $domainName.');
}