run method
Runs the task with optional parameters for customization.
Implementation
Future<T?> run({
bool? clear,
bool? throwOnError,
Function(Object)? onError,
StyleFunction? prompt,
StyleFunction? successHint,
StyleFunction? failedHint,
StyleFunction? successTag,
StyleFunction? failedTag,
}) async {
// Apply custom styles
final sPrompt = _style(this.prompt, prompt);
final sSuccessHint = _style(this.successHint?.cGray ?? '', successHint);
final sFailedHint = _style(this.failedHint?.cGray ?? '', failedHint);
final sSuccessTag = _style(this.successTag.dim(), successTag);
final sFailedTag = _style(this.failedTag.dim(), failedTag);
T? result;
await task(
sPrompt,
successMessage: _buildSuccessMsg(sPrompt, sSuccessHint, sSuccessTag),
failedMessage: _buildFailedMsg(sPrompt, sFailedHint, sFailedTag),
clear: clear ?? this.clear,
throwOnError: throwOnError ?? false,
onError: onError,
task: (state) async {
result = await execute(state);
},
);
return result;
}