completions property

  1. @override
Map<String, String?> get completions
override

A collection of MapEntry with completion suggestions to their descriptions.

Implementation

@override
Map<String, String?> get completions {
  final mapCompletions = <String, String?>{};
  for (final option in completionLevel.visibleOptions) {
    final isNegatable = option.negatable ?? false;
    if (isNegatable) {
      if (option.negatedName.startsWith(pattern)) {
        mapCompletions['--${option.negatedName}'] = option.help;
      } else {
        for (final negatedAlias in option.negatedAliases) {
          if (negatedAlias.startsWith(pattern)) {
            mapCompletions['--$negatedAlias'] = option.help;
          }
        }
      }
    }

    if (option.name.startsWith(pattern)) {
      mapCompletions['--${option.name}'] = option.help;
    } else {
      for (final alias in option.aliases) {
        if (alias.startsWith(pattern)) {
          mapCompletions['--$alias'] = option.help;
        }
      }
    }
  }
  return mapCompletions;
}