def __call__(self, argument_parser, always_complete_options=True, exit_method=os._exit, output_stream=None,
                 exclude=None, validator=None):

        if '_ARGCOMPLETE' not in os.environ:
            # not an argument completion invocation
            return

        global debug_stream
        try:
            debug_stream = os.fdopen(9, 'w')
        except:
            debug_stream = sys.stderr

        if output_stream is None:
            try:
                output_stream = os.fdopen(8, 'wb')
            except:
                debug("Unable to open fd 8 for writing, quitting")
                exit_method(1)

        if validator is None:
            validator = default_validator
        self.validator = validator

        self.always_complete_options = always_complete_options
        self.exclude = exclude

        # print("", stream=debug_stream)
        # for v in 'COMP_CWORD', 'COMP_LINE', 'COMP_POINT', 'COMP_TYPE', 'COMP_KEY', '_ARGCOMPLETE_COMP_WORDBREAKS', 'COMP_WORDS':
        #     print(v, os.environ[v], stream=debug_stream)

        ifs = os.environ.get('_ARGCOMPLETE_IFS', '\013')
        if len(ifs) != 1:
            debug("Invalid value for IFS, quitting [{v}]".format(v=ifs))
            exit_method(1)

        comp_line = os.environ['COMP_LINE']
        comp_point = int(os.environ['COMP_POINT'])

        # Adjust comp_point for wide chars
        if USING_PYTHON2:
            comp_point = len(comp_line[:comp_point].decode(sys_encoding))
        else:
            comp_point = len(comp_line.encode(sys_encoding)[:comp_point].decode(sys_encoding))

        if USING_PYTHON2:
            comp_line = comp_line.decode(sys_encoding)

        cword_prequote, cword_prefix, cword_suffix, comp_words, first_colon_pos = split_line(comp_line, comp_point)

        if os.environ['_ARGCOMPLETE'] == "2": # Hook recognized the first word as the interpreter
            comp_words.pop(0)
        debug(u"\nLINE: '{l}'\nPREQUOTE: '{pq}'\nPREFIX: '{p}'".format(l=comp_line, pq=cword_prequote, p=cword_prefix), u"\nSUFFIX: '{s}'".format(s=cword_suffix), u"\nWORDS:", comp_words)

        active_parsers = [argument_parser]
        parsed_args = argparse.Namespace()
        visited_actions = []

        '''
        Since argparse doesn't support much introspection, we monkey-patch it to replace the parse_known_args method and
        all actions with hooks that tell us which action was last taken or about to be taken, and let us have the parser
        figure out which subparsers need to be activated (then recursively monkey-patch those).
        We save all active ArgumentParsers to extract all their possible option names later.
        '''
        def patchArgumentParser(parser):
            parser.__class__ = IntrospectiveArgumentParser
            for action in parser._actions:
                # TODO: accomplish this with super
                class IntrospectAction(action.__class__):
                    def __call__(self, parser, namespace, values, option_string=None):
                        debug('Action stub called on', self)
                        debug('\targs:', parser, namespace, values, option_string)
                        debug('\torig class:', self._orig_class)
                        debug('\torig callable:', self._orig_callable)

                        visited_actions.append(self)

                        if self._orig_class == argparse._SubParsersAction:
                            debug('orig class is a subparsers action: patching and running it')
                            active_subparser = self._name_parser_map[values[0]]
                            patchArgumentParser(active_subparser)
                            active_parsers.append(active_subparser)
                            self._orig_callable(parser, namespace, values, option_string=option_string)
                        elif self._orig_class in safe_actions:
                            self._orig_callable(parser, namespace, values, option_string=option_string)
                if getattr(action, "_orig_class", None):
                    debug("Action", action, "already patched")
                action._orig_class = action.__class__
                action._orig_callable = action.__call__
                action.__class__ = IntrospectAction

        patchArgumentParser(argument_parser)

        try:
            debug("invoking parser with", comp_words[1:])
            with mute_stderr():
                a = argument_parser.parse_known_args(comp_words[1:], namespace=parsed_args)
            debug("parsed args:", a)
        except BaseException as e:
            debug("\nexception", type(e), str(e), "while parsing args")

        debug("Active parsers:", active_parsers)
        debug("Visited actions:", visited_actions)
        debug("Parse result namespace:", parsed_args)

        completions = self.collect_completions(active_parsers, parsed_args, cword_prefix, debug)
        completions = self.filter_completions(completions)
        completions = self.quote_completions(completions, cword_prequote, first_colon_pos)

        debug("\nReturning completions:", completions)
        output_stream.write(ifs.join(completions).encode(sys_encoding))
        output_stream.flush()
        debug_stream.flush()
        exit_method(0)
:param argument_parser: The argument parser to autocomplete on
dataset/ETHPy150Open dnanexus/dx-toolkit/src/python/dxpy/packages/argcomplete/__init__.py/CompletionFinder.__call__