runWithConfig method
Runs this command with prepared configuration (options). Subclasses should override this method.
Implementation
@override
Future<void> runWithConfig(
final Configuration<UnsetVariableCommandConfig> commandConfig,
) async {
final projectId = commandConfig.value(UnsetVariableCommandConfig.projectId);
final variableName = commandConfig.value(
UnsetVariableCommandConfig.variableName,
);
final shouldUnset = await logger.confirm(
'Are you sure you want to remove the environment variable "$variableName"?',
defaultValue: false,
);
if (!shouldUnset) {
throw UserAbortException();
}
final apiCloudClient = runner.serviceProvider.cloudApiClient;
try {
await apiCloudClient.environmentVariables.delete(
name: variableName,
cloudCapsuleId: projectId,
);
} on Exception catch (e, s) {
throw FailureException.nested(
e,
s,
'Failed to remove the environment variable',
);
}
logger.success('Successfully removed environment variable: $variableName.');
}