code: def flag_based_complete(self, text: str, line: str, begidx: int, endidx: int,
                              flag_dict: Dict[str, Union[Iterable, Callable]],
                              all_else: Union[None, Iterable, Callable] = None) -> List[str]:
          
          # Get all tokens through the one being completed
          tokens, _ = self.tokens_for_completion(line, begidx, endidx)
          if not tokens:
              return []
  
          completions_matches = []
          match_against = all_else
  
          # Must have at least 2 args for a flag to precede the token being completed
          if len(tokens) > 1:
              flag = tokens[-2]
              if flag in flag_dict:
                  match_against = flag_dict[flag]
  
          # Perform tab completion using a Collection
          if isinstance(match_against, Collection):
              completions_matches = self.basic_complete(text, line, begidx, endidx, match_against)
  
          # Perform tab completion using a function
          elif callable(match_against):
              completions_matches = match_against(text, line, begidx, endidx)
  
          return completions_matches
docs: Tab completes based on a particular flag preceding the token being completed
          :param text: the string prefix we are attempting to match (all returned matches must begin with it)
          :param line: the current input line with leading whitespace removed
          :param begidx: the beginning index of the prefix text
          :param endidx: the ending index of the prefix text
          :param flag_dict: dictionary whose structure is the following:
                            keys - flags (ex: -c, --create) that result in tab completion for the next
                                   argument in the command line
                            values - there are two types of values
                               1. iterable list of strings to match against (dictionaries, lists, etc.)
                               2. function that performs tab completion (ex: path_complete)
          :param all_else: an optional parameter for tab completing any token that isn't preceded by a flag in flag_dict
          :return: a list of possible tab completions