onBeforeRun<O extends OptionDefinition, T> static method

CommandMiddleware<O, T> onBeforeRun<O extends OptionDefinition, T>(
  1. FutureOr<void> onRun(
    1. CommandContext<O, T>
    )
)

Creates a CommandMiddleware with a variant of onRun that does not return a value, intended for use before the command is run but no need to change the context.

Implementation

static CommandMiddleware<O, T> onBeforeRun<O extends OptionDefinition, T>(
  final FutureOr<void> Function(CommandContext<O, T>) onRun,
) {
  return withHooks(
    onRun: (final ctx) async {
      await onRun(ctx);
      return ctx;
    },
  );
}