run method

  1. @override
FutureOr<int>? run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
// ignore: unnecessary_overrides
FutureOr<int>? run() async {
  final commands = {
    for (final key in subcommands.keys) key.toNoCase().toTitleCase(): key,
  };

  final choice = logger.chooseOne(
    'What would you like to create?',
    choices: commands.keys.toList(),
  );

  final key = commands[choice];

  final command = subcommands[key];

  if (command == null) {
    logger.err('Failed to find command');
    return -1;
  }

  final result = await command.run();

  return result ?? 0;
}