register method

  1. @override
void register(
  1. List<CliCommandContract> commands
)

Register your commands into the command line interface service.

Automatically register into the help command.

Implementation

@override
void register (List<CliCommandContract> commands) {
  for (final command in commands) {
    _commands.putIfAbsent(command.name, () => command);

    final ArgParser parser = ArgParser();
    if (command.arguments.isNotEmpty) {
      for (final argument in command.arguments) {
        parser.addOption(argument);
      }
    }

    _parser.addCommand(command.name, parser);
  }
}