def complete(self, text, state):
if state == <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>", text)<EOL>cword_prequote, cword_prefix, cword_suffix, comp_words, first_colon_pos = split_line(text)<EOL>print("<STR_LIT>".format(cword_prequote, cword_prefix, cword_suffix, comp_words, first_colon_pos))<EOL>comp_words.insert(<NUM_LIT:0>, "<STR_LIT>")<EOL>self.matches = self._get_completions(comp_words, cword_prefix, cword_prequote, first_colon_pos)<EOL>print("<STR_LIT>", self.matches)<EOL><DEDENT>if state < len(self.matches):<EOL><INDENT>print("<STR_LIT>", self.matches[state])<EOL>return self.matches[state]<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Alternate entry point for using the argcomplete completer in a readline-based REPL. See also
`rlcompleter <https://docs.python.org/2/library/rlcompleter.html#completer-objects>`_.

Usage:

.. code-block:: python

    import argcomplete, argparse, readline
    parser = argparse.ArgumentParser()
    ...
    completer = argcomplete.CompletionFinder(parser)
    readline.set_completer(completer.complete)
    readline.parse_and_bind("tab: complete")
    result = input("prompt> ")

(Use ``raw_input`` instead of ``input`` on Python 2, or use `eight <https://github.com/kislyuk/eight>`_).