addCommand method

  1. @override
void addCommand(
  1. CommandBuilder command
)
override

Implementation

@override
void addCommand(CommandBuilder command) {
  if (commands.contains(command)) {
    throw InvalidCommandException('Command $command already exists');
  }

  final name = command.name;

  if (name == null) {
    throw MissingPropertyException('Command name is required');
  }

  final handlers = command.reduceHandlers();

  commands.add(command);
  commandsHandler.addAll(handlers);

  // Collect autocomplete handlers from option trees.
  _registerAutocompleteHandlers(name, command);
}