run method

  1. @override
FutureOr<void> run(
  1. CommandContext context
)
override

Runs the command.

Implementation

@override
FutureOr<void> run(CommandContext context) {
  try {
    final command = commmand(context) ?? defaultCommand;
    if (command != null) {
      try {
        command.setup(context.input);
        return command.run(context);
      } catch (e) {
        command.printHelp(context);
        rethrow;
      }
    }

    printHelp(context);
  } on CommandError catch (error) {
    context.console.newline();
    final message =
        'Error: ${error.message}'.consoleText(style: ConsoleStyle.error);
    context.console.report(message);
  }
}