processActionRecipe method

  1. @override
bool processActionRecipe(
  1. ActionRecipe recipe,
  2. String regexTestString
)
override

Attempts to process a command for a recipe. Returns true if the regexTestString matches that of the processor currently running. The modifications are applied to the ActionRecipe provided.

Implementation

@override
bool processActionRecipe(ActionRecipe recipe, String regexTestString) {
  final selectManyWord =
      _selectWordLineNextPrevious.firstMatch(regexTestString);
  if (selectManyWord != null && selectManyWord.groupCount > 2) {
    final cmdAction =
        CommandUtils.setActionCommandVariant(selectManyWord.group(1) ?? "");
    final direction = selectManyWord.group(3) ?? "";
    var wordCount = WordToIntegerUtils.parse(selectManyWord.group(4) ?? "");
    wordCount = wordCount == 0 ? 1 : wordCount;
    final item = (selectManyWord.group(5) ?? "").toLowerCase();
    if (item.isNotEmpty && cmdAction.isNotEmpty && direction.isNotEmpty) {
      recipe.name = CommandUtils.setObjectType(item);
      recipe.nextPrevious = direction;
      recipe.chooseNumber = wordCount;
      recipe.receivedText = "";
      recipe.searchText = item;
      recipe.isCommand = true;
      recipe.selectFor = cmdAction == AugnitoCommands.select ? "" : cmdAction;
      return true;
    }
  }
  return false;
}